i no hwo to detect key board press combinations, but i dont no how to detect them anywhere on the desktop, i mean anywhere on the screen. please help
Printable View
i no hwo to detect key board press combinations, but i dont no how to detect them anywhere on the desktop, i mean anywhere on the screen. please help
Use the GetAsyncKeyState() API Within a Timer Controls Timer Event, ie.
private Declare Function GetAsyncKeyState Lib "user32" (byval vKey as Long) as Integer
private Sub Form_Load()
Timer1.Interval = 10
End Sub
private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyControl) <> 0 And GetAsyncKeyState(vbKeyQ) <> 0 then
Caption = "Pressing CTRL + Q"
else
Caption = ""
End If
End Sub
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Here's a pretty simple way of capturing a key event anywhere:
Put this in a module:
public Declare Function GetKeyState Lib "user32" (byval nVirtKey as Long) as Integer
here's a loop that will constantly look for a keypress of 8 asynchronously:
Do
DoEvents
i = GetKeyState(56)
If i = 1 then
MsgBox "8 was pressed"
Exit Do
End If
Loop