Press a key as long as the same key is being held down Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Raiden96
Posts: 38
Joined: 23 Oct 2021, 07:03

Press a key as long as the same key is being held down

Post by Raiden96 » 03 Jul 2022, 10:58

Hello,

I'm trying make a script that keeps on tapping E as long as i hold E down.

Code: Select all

#IfWinActive ".exe"
E:: ; celebration slide
SetKeyDelay, 50, 50
While GetKeyState("E", "P")
{
Send {E down}
Send {E up}
}
#IfWinActive
Return

I also want it to run only when a certain game is in focus. But if the script doesn't work i can't tell if the

Code: Select all

#IfWinActive
actually works or not. Thanks!

User avatar
mikeyww
Posts: 26938
Joined: 09 Sep 2014, 18:38

Re: Press a key as long as the same key is being held down  Topic is solved

Post by mikeyww » 03 Jul 2022, 11:17

Code: Select all

#IfWinActive ahk_exe notepad.exe
$e::
SetKeyDelay, 50, 50
While GetKeyState("e", "P")
 Send e
Return
#IfWinActive
Explained: Dollar prefixWinTitle

Raiden96
Posts: 38
Joined: 23 Oct 2021, 07:03

Re: Press a key as long as the same key is being held down

Post by Raiden96 » 03 Jul 2022, 11:52

My kind thanks once again sir. Works great!

Post Reply

Return to “Gaming Help (v1)”