Code: Select all
#MaxThreadsPerHotkey 2 ; This setting is used to control how many "instances" of a given hotkey or hotstring subroutine are allowed to exist simultaneously
and here 2 is usefull since we want stop the subroutine using the same hotkey
expression which alongside
untilis evaluated
after the inner loop is reached see:
https://autohotkey.com/docs/commands/Until.htm
so you have to check at each send, whith this aim in view you better off simplificate you multiline send by an expression with a
loop
Code: Select all
Loop, 4
MsgBox % ["w", "a", "s", "d"][a_index]
is the same as:
Code: Select all
MsgBox, w
MsgBox, a
MsgBox, s
MsgBox, d
and since with have a
loop in a
loop with have to call
break, 2 because if an inner loop is enclosed by an outer loop, the inner loop takes precedence
(see:
https://autohotkey.com/docs/commands/Loop.htm)
Code: Select all
#MaxThreadsPerHotkey 2
toggled=0
^l::
if (toggled=0)
{
toggled=1
Loop
{
Loop, 4
{
; Send % "{" . ["w", "a", "s", "d"][a_index] . A_Space . (mod(a_index, 2) ? "up" : "down") . "}"
; EDIT:
Send % "{" . ["w", "w", "a", "a", "s", "s", "s", "d", "d"][a_index] . A_Space . (mod(a_index, 2) ? "up" : "down") . "}"
Sleep 1000
if not toggled
break, 2
}
}
}
else
{
MsgBox, exit
toggled=0
}
return