-
I have a number of "special" rubber shortcut keys on my keyboard. Can VB catch these when they are pressed? Windows2k doesn't support the software that came with it and I'd like to make a replacement.
Win2k does however support the Volume/Mute buttons for some reason..? But no OSD obviously :(
«davidc»
-
To capture keys, use the GetAsyncKeyState API function.
Code:
Private Declare Function GetAsyncKeyState _
Lib "user32.dll" (ByVal vKey As Long) As Integer
Privatei Sub Timer1_Timer()
Dim iKey As Integer
For iKey = 3 to 255
If GetAsyncKeyState(iKey) Then Caption = Chr(iKey)
Next iKey
End Sub
-
Thanks... I'll give it a go!
«davidc»
-
Eeeerrrkkk!
OK, so that works fine barr 3 buttons. I have modified the code slightly so that it doesn't convert it to an ASCII code, as I'd like my program to check against a table of numbers.
However, there are three buttons at the top right which are playing up. One is HK2 (a hotkey), the second is COFFEE BREAK (screensaver) and the third is Menu/i (Originally an F1 help style thing)
Two of these buttons are the ones I am trying to catch.. and all three return 255 as a keycode..! I'm sensing something strange going on. Increasing the loop to 300 doesn't make a difference (I didn't think it would sadly!). So how can I distinguish between these keys? It must be possible, as the software which shipped with the keyboard originally managed somehow!
Thanks again,
«davidc»