0

In Autohotkey, I know you can use "KeyWait" to wait for a key to be pressed or released, but what can I do if I want to be able to wait for either of two keys to be released?

I found this on the web, but it is when you want to wait for either of two keys to be pressed

LButton & XButton1::
Keywait, r
Keywait, LAlt
SendInput {ShiftDown}
SendInput {v Down}
SendInput {v Up}
SendInput {Shift Up}

Input, UserInput,v,{LButton}{XButton1}
;v is if you want input to be visible
if ErrorLevel=EndKey:LButton
{
    theFunctionIrunAlltheTime()
    Return
}
else if ErrorLevel=EndKey:XButton1
{
    theFunctionIrunAlltheTime()
    Return
}

No matter which of those Buttons is release I want to do the same, I think the example above works only with letters, not with Buttons, but the important thing here is that by the time the script is run, LButton n XButton1 are already pressed and I want in the middle of the subroutine to detect when any of them is released, any idea please??? thanks adavanced.

2 Answers 2

0

Try also this:

~LButton & XButton1::
SetTimer detect_key_released, 50
; do sth
return

    detect_key_released:
If !GetKeyState("LButton", "P")
{
    SetTimer detect_key_released, off
    MsgBox LButton released
    return
}
If !GetKeyState("XButton1", "P")
{
    SetTimer detect_key_released, off
    MsgBox XButton1 released
    return
}
return
1
2
While GetKeyState("LButton") && GetKeyState("XButton1")
    Sleep 10

; msg to user assumes only one or the other was released...
MsgBox % (GetKeyState("LButton") ? "XButton1" : "LButton") " Released"
1
  • thanks JJohnston2, is not possible to do it wo using a loop right? btw could you please take a look at this question? thanks advanced.superuser.com/questions/1177548/…
    – litu16
    Feb 11, 2017 at 12:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .