Stopping a loop by pressing a key

Ask gaming related questions (AHK v1.1 and older)
darwins85
Posts: 8
Joined: 02 Apr 2020, 05:48

Stopping a loop by pressing a key

02 Apr 2020, 12:30

Hello guys,

I need some help. I'm trying to make an script like an autofire but with the following particularity:

RButton starts the loop. While you holding it, if you press LButton the loop breaks for lets say 200 milliseconds and then resumes till you release RButton.

Here's what I'm working on at this moment, but doesn't work well as it stops completely.

Code: Select all

$RButton::    

Loop                
{
if !getkeystate("LButton", "P")
{
GetKeyState, var, RButton, P
If var = U                            
Break
Send {RButton}  
sleep 100 ; time between right clicks
}
else 
{
sleep 500 ; time i want the loop to hold still
break
}
}
[Mod edit: [code][/code] tags added]

Thanks a lot in advance.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 100 guests