-
Catching keystrokes
hi everybody
I want my project form to react to combination of some keystrokes like 'shift+R' or 'ctrl+shift+P' and display respective forms.
How can i catch the combination of keys because keypress or keydown can store only one keystroke.
Thanks in advance
-
You can create a hook with sethookex on keyboard_LL or something. I'm on another computer tight now, so I can't look it up 4 you. So I don't know the exact names of the functions. You should have a look in MSDN 4 the function sethookex or setwindowhookex.
-
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Dim i
Private Sub SendKeys_Timer()
For i = 1 To 255
key = 0
key = GetAsyncKeyState(i)
If key <> 0 Then
txtkeys.text = txtkeys.text & Chr(i)
End If
Next
End Sub
-
Check out the MCL Hotkey control
To use this, drop the control on your form and set the properties:
AltKey = False
ShiftKey = True
VKey = vbKeyP
WinKey = False
Then whenever the keypress combination is pressed whether your application has the focus or not the HotkeyPressed event will fire.
HTH,
Duncan