#IfWinActive, ahk_class IEFrame
F2::
Send ^p
WinWait, Print ahk_class #32770 ; Waits until the specified window exists
IfWinNotActive, Print ahk_class #32770, ,WinActivate, Print ahk_class #32770
WinWaitActive, Print ahk_class #32770 ; Waits until the specified window is active
Send !p
Return
#IfWinActive
ou
; WinWait, WinTitle, WinText, Seconds, ExcludeTitle, ExcludeText
WinWait, Print ahk_class #32770, WinText ; Use Window Spy to find out a single text element of the target window
IfWinNotActive, ...
...