My program uses the GetAsyncKeyState API call to record the keystrokes sent to other applications. The problem with this call, unless I am doing something terribly wrong, is that it doesn't seem able to intercept combination keystrokes. It returns codes for the uppercase version of letters A-Z regardless of the shift-state. When Shift+"A" is pressed it returns the SHIFT key code rather than the code for "a". When ALT+F12 is pressed it returns the code for the ALT key.
I have tried a variety of Jerry-Rigs trying to guess the actual key presses (e.g., set a flag when CAPSLOCK is pressed and assume everything that follows is UPPERCASE... unless the SHIFT key is pressed, etc). Nothing seems solve the problem.
Does anybody know of a different function to derive the true keystrokes or a way to coerce GetAsyncKeyState into telling the truth?
Here's the tiny bit of code I'm using....
[tt]
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
Public Function GetInput()
For Rep = 0 To 255
If (GetAsyncKeyState(Rep) And &H8001) <> 0 Then
GetInput = Rep
Exit Function
End If
Next i
End Function
[/tt]
I know there must be a way to do this. I'm probably blinded by a solution that is so close I can't see it.
I have tried a variety of Jerry-Rigs trying to guess the actual key presses (e.g., set a flag when CAPSLOCK is pressed and assume everything that follows is UPPERCASE... unless the SHIFT key is pressed, etc). Nothing seems solve the problem.
Does anybody know of a different function to derive the true keystrokes or a way to coerce GetAsyncKeyState into telling the truth?
Here's the tiny bit of code I'm using....
[tt]
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
Public Function GetInput()
For Rep = 0 To 255
If (GetAsyncKeyState(Rep) And &H8001) <> 0 Then
GetInput = Rep
Exit Function
End If
Next i
End Function
[/tt]
I know there must be a way to do this. I'm probably blinded by a solution that is so close I can't see it.