WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Detect Keyboard Tricks

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Another Example to Monitor Keypresses

Keywords: 	  monitor keyboard presses detect a key check any key pressed down

You can even determine which key has been pressed it works good from 0-9 A-Z
sDLLName = StrCat(DirWindows(1), "user32.dll")
before = BinaryAlloc(256)
DllCall(sDLLName, long:"GetKeyboardState", lpbinary:before)
BinaryEodSet(before, 256) 

BoxOpen("","Press any key.")

after=BinaryAlloc(256)
While 1
	DllCall(sDLLName, long:"GetKeyboardState", lpbinary:after)
	BinaryEodSet(after, 256) 
	If BinaryCompare(before, 0, after, 0, 256)==@FALSE Then Break
EndWhile

count=0
x=0
While 1
	x=BinaryPeek(after, count)
	If x<>0 && x<>1 Then Break
	count=count+1
EndWhile

Message("",StrCat("You pressed: ", Num2Char(count)))

BinaryFree(after)
BinaryFree(before)

Article ID:   W15694
File Created: 2003:05:13:11:29:36
Last Updated: 2003:05:13:11:29:36