How do I make GetAsyncKeyState detect if Caps Lock is toggled?

May 12, 2019 at 1:23am
So i am trying to make a program that holds down right-click when Caps Lock is on and doesnt click when it is off. Currently I have my if statement saying:
if ((GetAsyncKeyState(VK_CAPITAL)& 0x0001)!=0)
then it declares the rightdown mouse event, which works perfectly fine. My problem is that instead of detecting when or not Caps Lock is toggled, it only detects when the key is pressed. How do I make it so that it proceeds to do the mousevent only when the caps lock is toggled on and just start the click as soon the key is pressed?
May 12, 2019 at 3:51am
Aren't you supposed to test the most significant bit?

 
if (GetAsyncKeyState(VK_CAPITAL) & 0x8000)

You could also try GetKeyState instead: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getkeystate

Topic archived. No new replies allowed.