Reputation: 23
So I need the current script below, to be able to toggle.
At the moment, the script only work when holding down the F8 key... which defeats the point of a afk script. lol
Anyhow, here's the script:
$F8::
Loop
{
if not GetKeyState("F8", "P")
break
Click right
Click
Send {Numpad7 down}
Send {Numpad7 up}
}
return
Would anyone be able to turn this into a toggle
please? Any help is much appreciated!
Upvotes: 2
Views: 12387
Reputation: 4065
Your attempt using a toggle variable (as per the code from your comment) is the right approach, but there are few things missing:
Toggle := !Toggle
does with an unitialized Toggle
? It could be true
or false
; most compilers wouldn't even allow it.SetBatchLines
and SetKeyDelay
. But at the latest when those delays are reduced, the send speed could not only be overkill, but also affect the target application or even your system performance. That's why Sleep
or SetTimer
with an adequate delay should be used.Here's an untested suggestion:
toggle := false
$F8::
if(toggle) {
toggle := false
SetTimer, SendSomething, Off
} else {
toggle := true
; Choose a delay here!
SetTimer, SendSomething, 100
}
return
SendSomething:
Click right
Click
Send {Numpad7}
return
Upvotes: 6