2
votes

trying to make a toggle-able loop, seems to be not sending e at all, help please?

myvar := false
k::
myvar := true ? false : true
return
while (myvar)
{
Send, e
Sleep 100
}
2
to be clear, the behavoir i was trying to create is; do nothing, k is pressed, repeatedly send e until k is pressed again. - Cookie Cookie
Check your ternery operator. - Richard Yan
see edit below. - ChickenFeet

2 Answers

1
votes

Here is my suggestion:

k::SetTimer, SendLetterE, % (Toggle:=!Toggle) ? 100 : "Off"

SendLetterE() {
    Send, e
}
-1
votes

You can assign another key to pause / resume. In this case k will toggle and F12 will run indefinitely (so just use k to toggle).

k::
Hotkey, F12, toggle
return

F12::
while(true)
{
    Send, e
    Sleep 100
}

Could also try Loop instead of while(true)

k::
pause, toggle

F12::
Loop,
{
    Send e
    Sleep, 100
}
return

referenced from AutoHotkey forum.