To get instant notification of a window, use the Shell Hook. It is sometimes so fast that an autohotkey can react before you even see the window yourself.
The shell of the shell is shown on the AutoHotkey forum .
An example with your use (almost copied verbatim from a forum post):
#Persistent SetBatchLines, -1 Process, Priority,, High Gui +LastFound hWnd := WinExist() DllCall( "RegisterShellHookWindow", UInt,hWnd ) MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" ) OnMessage( MsgNum, "ShellMessage" ) Return ShellMessage( wParam,lParam ) { If ( wParam = 1 ) ; HSHELL_WINDOWCREATED := 1 { WinGetTitle, Title, ahk_id %lParam% If ( Title = "WorkRest" ) WinClose, ahk_id %lParam% ; close it immideately } }
If you want to use the literal character% in a command, output it using the AutoHotkey escape character, the back of `(on the same key as ~ on the US keyboard), for example:
MsgBox You are 200`% awesome!
source share