I want an AutoHotKey script that waits for a particular window and then sends keystrokes to that window. However, since the waiting is done in a loop, the keys are sent again and again.
Let's say I want to wait for Windows Calculator and then send "12345" to it. My first attempt was:
#SingleInstance force
Loop
{
WinWaitActive, Calc
{
Send, 12345
}
This script obviously sends "12345" over and over again since I'm not breaking out of the loop.
If I insert a "break" following the send statement, the loop terminates but so does the entire script.
What's the standard pattern for handling this?
Best Answer
I'm assuming you want to stop sending
12345
until you activate the window again (or another window with the same name). So useWinWaitNotActive