Check that no keys are being pressed
Check that no keys are being pressed
For Windows, what's the best way to ensure that the user isn't pressing down any keys at any given time, no matter which app has the focus? Looping all virtual key code states with GetAsyncKeyState and checking for 0 status isn't efficient nor working reliably, so I'm looking for an alternative solution. Thanks.
Re: Check that no keys are being pressed
Remove Keyboard
No.
Search forum to KeyboardHook
No.
Search forum to KeyboardHook
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Check that no keys are being pressed
A very clean and simple method is the GetLastInputInfo API (but be aware that this includes both mouse and keyboard input):
Code: Select all
LII.LASTINPUTINFO
LII\cbSize = SizeOf(LASTINPUTINFO)
Repeat
GetLastInputInfo_(@LII)
Debug LII\dwTime
Delay(1300)
ForEver
Re: Check that no keys are being pressed
@firace
LASTINPUTINFO is a predefined structure, right?
Is there a compilation for PureBasic of these structures,
that you don't need to define yourself?
LASTINPUTINFO is a predefined structure, right?
Is there a compilation for PureBasic of these structures,
that you don't need to define yourself?
Re: Check that no keys are being pressed
Try the Structure Viewer IDE tool (Alt+S) for a full list (and double-click a structure to display its members).highend wrote:@firace
LASTINPUTINFO is a predefined structure, right?
Is there a compilation for PureBasic of these structures,
that you don't need to define yourself?
Re: Check that no keys are being pressed
Thanks, firace!
Re: Check that no keys are being pressed
Thanks firace, I did a GetLastInputInfo to wait for no input for 50 milliseconds and it seems to be working fine. Great idea!