Hi guys, I can detect key strokes using the keydown function, but this only works when the form has focus, I am after a way to detect all keystrokes despite what program has the focus, can any one help?
Detecting keystrokes in VB 2005
Started by day1118, Dec 15 2007 12:55 PM
2 replies to this topic
#1
Posted 15 December 2007 - 12:55 PM
#2
Posted 15 December 2007 - 12:56 PM
DirectInput should be able to do that.
"Stupid bug! You go squish now!!" - Homer Simpson
#3
Posted 17 December 2007 - 11:35 AM
Declare Function GetAsyncKeyState Lib "user32" ( _
ByVal vKey As Long) As Integer
This function should help you too if you don't want to use DirectInput....
This function also receives ctrl and alt keys. And the form doesn't need to be focused.
But you should call it in your Program loop, you don't get an event you only get the state of the wished Key (pressed or not pressed).
If you don't have your own program loop you should put it there:
I think the routine is called WndProc
I'm not sure but i guess the code goes like that:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
'Add your code here
End Sub
ByVal vKey As Long) As Integer
This function should help you too if you don't want to use DirectInput....
This function also receives ctrl and alt keys. And the form doesn't need to be focused.
But you should call it in your Program loop, you don't get an event you only get the state of the wished Key (pressed or not pressed).
If you don't have your own program loop you should put it there:
I think the routine is called WndProc
I'm not sure but i guess the code goes like that:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
'Add your code here
End Sub
Visit my Homepage Skaldi Games
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












