0
votes

So I am making my script

toggl:=false
while(1){
	if(toggl){
		Send,E
	}
	Sleep, 150
}
!r::
toggl:=!toggl
return
!y::ExitApp,101

Problem is that while the loop is running, I can not cancel it because it blocks !y, so I had to restart computer. So any help with this would be nice.

1
Hint: use GetKeyState inside the loop.wOxxOm
Can you give me exact code, sorry im really new to AHKmobinblack
Hint is a hint. You can use it to find an existing answer.wOxxOm
You should describe what you want your script to do. While we might be able to infer this by reading your code, we can only guess at how you want it to behave.Jim U

1 Answers

0
votes

Set #MaxThreads 2 to allow each hotkey to run twice, OR:

Use SetTimer to allow the hotkey to end and continue your loop in a "Pseudo-Thread".

toggle := 0

F12::
    toggle := !toggle
    if (toggle){
        SetTimer, DoLoop, -100
    }
    return

DoLoop:
    Loop {
        if (!toggle){
            break
        }
        ; [Do your stuff here]
    }
    return