Press and Hold "e" until any key pressed

Ask gaming related questions (AHK v1.1 and older)
JohnyJ
Posts: 2
Joined: 03 Apr 2024, 13:31

Press and Hold "e" until any key pressed

03 Apr 2024, 13:51

Hey guys. Looking for a script that when I press "F1" it sends "e" and holds it down until any other key is pressed. Can't figure out the "any other key is pressed" part. I have one script that holds "e" key but it only releases it when the same key is pressed.
Rohwedder
Posts: 7895
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Press and Hold "e" until any key pressed

04 Apr 2024, 00:06

Hallo,
try:

Code: Select all

Hotkey, IF, AnyKey
For all, LF in [[0x1FF,"sc{:X}"],[0xFE,"vk{:X}"]]
    Loop,% LF.1
        IF (""<Key:=GetKeyName(Format(LF.2, A_Index)))
            Hotkey, ~*%Key%, AnyKey
Return
#IF !AnyKey
F1::
Send, {e Down}
ToolTip, e Down ; for Test only
AnyKey := True
KeyWait, F1
Return
#IF AnyKey
AnyKey:
AnyKey := False
Send, {e Up}
ToolTip ; for Test only
Return
#IF
or with AutoRepeat of key E:

Code: Select all

Hotkey, IF, AnyKey
For all, LF in [[0x1FF,"sc{:X}"],[0xFE,"vk{:X}"]]
    Loop,% LF.1
        IF (""<Key:=GetKeyName(Format(LF.2, A_Index)))
            Hotkey, ~*%Key%, AnyKey
Return
#IF !AnyKey
F1::
SetTimer, e Up, 30
AnyKey := True
KeyWait, F1
Return
#IF AnyKey
e Up::Send, {e Down}
AnyKey:
SetTimer, e Up, Off
AnyKey := False
Send, {e Up}
Return
#IF
JohnyJ
Posts: 2
Joined: 03 Apr 2024, 13:31

Re: Press and Hold "e" until any key pressed

04 Apr 2024, 05:36

@Rohwedder
This works perfectly!!!!! Thanks you so much

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: LJC2004, Strat919 and 42 guests