Hey guys I apologize for posting as a guest and being too lazy to register. I also apologize if this question's been asked a million times or if this seems pretty basic.
I need a macro to perform various functions in three different programs, and loop infinitely until interrupted by a hotkey set. I can't get it to do this. Either of these occurs:
1. Loops infinitely and ignores hotkey presses.
2. Goes once, then stops.
Currently #1 is my issue, here's my code:
Code:
#MaxThreadsPerHotkey 3
#z:: ; Win+Z hotkey (change this hotkey to suit your preferences).
#MaxThreadsPerHotkey 1
if KeepWinZRunning
{
KeepWinZRunning := false ; Signal that thread's loop to stop.
return ; End this thread so that the one underneath will resume and see the change made by the line above.
}
; Otherwise:
KeepWinZRunning := true
Loop
{
WinWait, REC,
IfWinNotActive, REC, , WinActivate, REC,
WinWaitActive, REC,
MouseClick, left, 102, 117
Sleep, 5000
WinWait, Calculator,
IfWinNotActive, Calculator, , WinActivate, Calculator,
WinWaitActive, Calculator,
MouseClick, left, 136, 24
Sleep, 1000
Send, {+}0.48{ENTER}
WinWait, REC1 - Notepad,
IfWinNotActive, REC1 - Notepad, , WinActivate, REC1 - Notepad,
WinWaitActive, REC1 - Notepad,
MouseClick, left, 126, 21
Sleep, 1500
Send, {SPACE}48{CTRLDOWN}s{CTRLUP}
WinWait, REC,
IfWinNotActive, REC, , WinActivate, REC,
WinWaitActive, REC,
MouseClick, left, 22, 125
Sleep, 100
; But leave the rest below unchanged.
if not KeepWinZRunning ; The user signaled the loop to stop by pressing Win-Z again.
break ; Break out of this loop.
}
KeepWinZRunning := false ; Reset in preparation for the next press of this hotkey.
return