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

时间:2010-02-14 13:14:55

标签: vbscript

我正在寻找一种方法来检测和关闭带有VBScript的开放系统消息框。

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

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

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

揍你。

2 个答案:

答案 0 :(得分:2)

下面的脚本将完全符合我的要求。

' 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 

答案 1 :(得分:0)

由于你有激活和关闭消息框的代码,我猜你所做的任何事情可能会或可能不会导致消息框出现,如果有的话你需要一种方法来清除它。

一种方法是启动第二个脚本,该脚本只包含一个监视消息框的循环,并在找到它时将其关闭。您可以在一段时间后将其编码为超时,以便完成主脚本。