Is it possible to WinWaitActive
for two (or more) different window titles at the same time? I'm executing a command and there could be a successful VNC Window coming up or a dialog telling me that the connection failed.
run, vnc.cmd, , Hide , PID ;# Launch hidden
WinWait, TurboVNC info, ;# The Warning
MsgBox A
WinWait, VNC manager [Raw] - 99`%,
MsgBox B
So this minimal example obviously doesn't work if the VNC shows correctly, as B
is never reached sequentially. So it was tried to combat this with timers, I thought they had separate threads:
run, vnc.cmd, , Hide , PID ;# Launch hidden
SetTimer, wait_for_graphical_vnc_own_thread, -1 ;# previously I had a 0 here, but that was not the problem's source
WinWait, TurboVNC info, ;# The Warning
MsgBox A
wait_for_graphical_vnc_own_thread:
WinWait, VNC manager [Raw] - 99`%, ;# Successful window
MsgBox B
Unfortunately, this does also not work, not even with another (second) timer for the warning. The next thing I tried was taken from this deprecated board:
Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt, hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return ; // End of Auto-Execute Section //
ShellMessage( wParam,lParam ) {
If ( wParam = 4 ) ; HSHELL_WINDOWACTIVATED
{
WinGetTitle, Title, ahk_id %lParam%
MsgBox %Title% ;# Not even this is ever shown
If InStr( Title, "TurboVNC info" ) {
MsgBox A2
}
If InStr( Title, "VNC manager [Raw] - 99`%" ) {
MsgBox B2
}
}
While I like the idea, it launches neither of the two. The author points to this board question on how to Hook on to Shell to receive its messages (archive link) for more details. The last idea comes from this answer to a question about AutoIt:
SetTitleMatchMode, RegEx
WinWait, TurboVNC info|VNC manager [Raw] - 99`%,
MsgBox C
;# I would then have a condition here to separate the two cases, but not even C gets shown
I found a workaround. Calling:
run, vnc_close_helper.ahk, PID_ch
Actually runs in a separate thread. The helper script then contains the second WinWaitActive
I need.