VBScript 检测打开的消息框并关闭它

VBScript 检测打开的消息框并关闭它

问题描述:

我正在寻找一种使用 VBScript 检测和关闭打开的系统消息框的方法.

I'm looking for a way to detect and close an open system messagebox with VBScript.

使用以下脚本,我可以将消息置于前台并关闭它:

Using the following script, I can bring the message to foreground and close it:

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActive "System Settings Change"
WshShell.SendKeys "%N"

问题:我需要一种方法来检测消息框是否正在使用 VBsciprt 等待用户交互,以便我可以关闭它.

The Question: I need a way to detect if a messagebox is waiting user interaction using VBsciprt so I can close it.

谢谢你.

下面的脚本将完全按照我的要求执行.

The script below will do exactly what I asked.

' Will loop forever checking for the message every half a second  
' until it finds the message then it will send Alt-N and quit. 

Set wshShell = CreateObject("WScript.Shell") 

Do 
    ret = wshShell.AppActivate("System Settings Change") 
    If ret = True Then 
        wshShell.SendKeys "%N" 
        Exit Do 
    End If 
    WScript.Sleep 500 
Loop