Global $Paused
HotKeySet("{END}", "TogglePause")
HotKeySet("{HOME}", "Terminate")
While 1
Sleep(100)
WEnd
Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
MouseClick("Left")
WEnd
EndFunc
Func Terminate()
Exit 0
EndFunc
Take that concept and change it to target the window. That is a much better (and convenient) way to do it. That script does nothing until you unpause it by pressing (END), at which point it clicks over and over until you press (END) again. When you want the program to actually close, you press (HOME). I'm sure you can figure out how to make that press a key instead of click and send it.