Reading GetKeyboardState_() result

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Reading GetKeyboardState_() result

Post by Kwai chang caine »

Hello at all

Still in my quest to understand how the keyboard and his API works
After try to studing a RASHAD code, i have not understand how GetKeyboardState_() use this array of string, for writing into him the bits of the state of the keyboard :oops:
Someone can show me, how read this array, for obtain ths state of SHIFT/CTRL/ALT, etc ....

Code: Select all

Dim Key.s(256)
GetKeyboardState_(@Key())

For i = 0 To 256
 Debug Key(i)
Next
Have a good day
ImageThe happiness is a road...
Not a destination
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: Reading GetKeyboardState_() result

Post by Olli »

Kwai chang caine wrote: Thu Jan 26, 2023 2:56 pm Hello at all

Still in my quest to understand how the keyboard and his API works
After try to studing a RASHAD code, i have not understand how GetKeyboardState_() use this array of string, for writing into him the bits of the state of the keyboard :oops:
Someone can show me, how read this array, for obtain ths state of SHIFT/CTRL/ALT, etc ....

Code: Select all

Dim Key.s(256)
GetKeyboardState_(@Key())

For i = 0 To 256
 Debug Key(i)
Next
Have a good day
Hello Keyssissi ! How are you ? You have again blended several things before you smoke them...

Code: Select all

Dim Key.A(255)
GetKeyboardState_(@Key(0) )

For i = 0 To 255
 Debug Key(i)
Next
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Reading GetKeyboardState_() result

Post by infratec »

https://learn.microsoft.com/en-us/windo ... boardstate

Code: Select all

Dim Key.A(255)
GetKeyboardState_(@Key(0) )

For i = 0 To 255
  If Key(i) & %10000000
    Debug "VK: " + Str(i) + " is down"
  EndIf
Next

Debug ""
 
Debug "VK_LSHIFT: " + Bool(Key(#VK_LSHIFT) & %10000000)
Debug "VK_RSHIFT: " + Bool(Key(#VK_RSHIFT) & %10000000)
Debug "VK_LCONTROL: " + Bool(Key(#VK_LCONTROL) & %10000000)
Debug "VK_RCONTROL: " + Bool(Key(#VK_RCONTROL) & %10000000)
Debug "VK_LMENU: " + Bool(Key(#VK_LMENU) & %10000000)
Debug "VK_RMENU: " + Bool(Key(#VK_RMENU) & %10000000)
Last edited by infratec on Thu Jan 26, 2023 3:41 pm, edited 1 time in total.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Reading GetKeyboardState_() result

Post by Kwai chang caine »

Thanks a lot at you two for this faster help
Furthermore ...this time i have understand yours codes 8)

You use Dim Key.A(255)
Then, is it an error of RASHAD to use a string array Dim Key.s(256) ?


@OLLI
Hello OLLI with two wings :D
I'm happy to read you...there are a very long time i have not read your incompressible writting :wink: :lol:
ImageThe happiness is a road...
Not a destination
Post Reply