Problem using GetKeyState

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Lem2001
Posts: 127
Joined: 27 Jun 2017, 17:59

Problem using GetKeyState

17 Apr 2021, 13:21

I'm trying to use GetKeyState to detect when a key is in the up/unpressed state and then use that to trigger the release/unpress of a couple of other keys. But it's not working.

I don't know if I'm using the command correctly.

Code: Select all

Appskey & Up::
Send, {LWin down}{Alt down}{up down}
KeyWait, up
GetKeyState, state, Appskey, p
If (state = "U")
Send, {LWin up}{Alt up}
return
The above code is working how I want it to work, except that when I release Appskey (so that its state = U) it is not sending {LWin up}{Alt up}.

Can anybody help me understand why LWin and Alt remain pressed even after sending {LWin up}{Alt up}?

P.S. A bit of context just in case anybody proposes a solution that differs significantly from my example code above: I need this hotkey to work globally, and I also use my Appskey as a modifier key in addition to using its normal context-menu function (all of which is currently working perfectly, even with the above code). Therefore I'm trying to avoid any solution that will break any of the pre-existing Appskey functionality that I already have.
User avatar
boiler
Posts: 16954
Joined: 21 Dec 2014, 02:44

Re: Problem using GetKeyState

17 Apr 2021, 13:39

You are waiting until the Up key is released then immediately checking to see if the Apps key is released or not. Unless you release it before you release the Up key, it will never be released at that time. It sounds like you really want to use KeyWait on the Apps key or both keys, not GetKeyState.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: FanaticGuru, filipemb, Google [Bot], LRRUNB and 232 guests