INF: Use of GetInputState() Is Faster Than Using PeekMessage()

ID Number: Q35605

2.03 2.10 3.00

WINDOWS

Summary:

The following information discusses an alternative way to quickly

determine if there any are keyboard or mouse messages without having

to use Get/PeekMessage().

For this type of task, it is faster to use the GetInputState()

function. GetInputState() will return TRUE if either a keyboard or

mouse event has occurred. If it is necessary to distinguish between a

mouse or a keyboard message, check the return value. It will be 2 for

the keyboard and 1024 for the mouse.

Problems may occur if the application loses the focus; therefore, this

function should only be used under tight loop conditions.