Putting a settimer to turn off loop Topic is solved

Ask gaming related questions (AHK v1.1 and older)
ishida20
Posts: 4
Joined: 11 Mar 2024, 10:32

Putting a settimer to turn off loop

Post by ishida20 » 11 Mar 2024, 10:38

So I have this code where it loops F1>Click>F2 and has the 5:: function to have it turned off and on
Can anyone help with putting a settimer or any command that when I press 5 to start the command, it'll start looping and after a set time it will press END>F9 and then turn off the loop?
I tried fiddling with the source code and ultimately cannot achieve this. Any help would be appreciated.

Code: Select all

#MaxThreadsPerHotkey 3
5::
#MaxThreadsPerHotkey 1
if KeepWinZRunning
{
KeepWinZRunning := false
return
}
KeepWinZRunning := true
Loop
{
Send {F1}
Sleep 0
MouseClick, Left
Send {F2}
Sleep 100
if not KeepWinZRunning
break
}
return
ESC::ExitApp
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]
[Mod edit: Moved topic from AHK v2 help to v1 help, based on posted code.]

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

Re: Putting a settimer to turn off loop  Topic is solved

Post by mikeyww » 11 Mar 2024, 11:37

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v1.1.33.11
#MaxThreadsPerHotkey 2

5::
KeepWinZRunning := !KeepWinZRunning
SoundBeep 1000 + 500 * KeepWinZRunning
end := A_TickCount + 2000
While KeepWinZRunning && A_TickCount <= end {
 Send {F1}
 If KeepWinZRunning
  Send {LButton}{F2}
 If KeepWinZRunning
  Sleep 100
}
If (A_TickCount > end)
 SoundBeep 1000
KeepWinZRunning := False
Return

ishida20
Posts: 4
Joined: 11 Mar 2024, 10:32

Re: Putting a settimer to turn off loop

Post by ishida20 » 11 Mar 2024, 16:43

That is mint! Working like a charm, and with the added beep if I may add. Thank you so much mikeyww, much appreciated!

Post Reply

Return to “Gaming Help (v1)”