Sign in to follow this  
Followers 0
SocramMalaquias

Help with GetKeyboardState

1 post in this topic

I'm using the following code to test the GetKeyboardState from USER32.DLL:

$key = DllStructCreate("byte[256]")
$key2 = DllStructCreate("byte[256]")
DllCall("user32.dll", "int", "GetKeyboardState", "ptr", DllStructGetPtr($key))
Sleep(1000)
DllCall("user32.dll", "int", "GetKeyboardState", "ptr", DllStructGetPtr($key2))
For $a = 0 to 0xFF
    If DllStructGetData($key, 1, $a) <> DllStructGetData($key2, 1, $a) Then
        ConsoleWrite("--->")
    EndIf
    ConsoleWrite(Hex($a, 2) & "(" & DllStructGetData($key, 1, $a) & DllStructGetData($key2, 1, $a) & ")" & @CRLF)
Next

I press the CAPS LOCK (or other letter) in the Sleep() time, but the function detects no change. If I close the program, it detects the change :/. Why it doesn't work?

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0