【发布时间】:2022-01-12 10:19:59
【问题描述】:
是否可以同时WinWaitActive 为两个(或更多)不同的窗口标题?我正在执行一个命令,可能会出现一个成功的 VNC 窗口或一个对话框告诉我连接失败。
run, vnc.cmd, , Hide , PID ;# Launch hidden
WinWait, TurboVNC info, ;# The Warning
MsgBox A
WinWait, VNC manager [Raw] - 99`%,
MsgBox B
因此,如果 VNC 正确显示,这个最小示例显然不起作用,因为永远不会按顺序到达 B。所以它试图用计时器来解决这个问题,我认为它们有单独的线程:
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
不幸的是,这也不起作用,即使使用另一个(第二个)计时器来发出警告也是如此。接下来我尝试的是取自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
}
}
虽然我喜欢这个想法,但两者都没有推出。作者指向this board question on how to Hook on to Shell to receive its messages (archive link)了解更多详情。最后一个想法来自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
【问题讨论】:
标签: automation autohotkey ui-automation vnc-viewer