在不到一秒的时间内显示消息框

时间:2012-07-30 07:41:54

标签: vbscript

有没有办法让msgbox显示并在一秒钟内消失,我一直在使用下面的脚本,但只能让它在一秒钟内关闭。

选项明确 Dim Wshell,BtnCode 设置Wshell = CreateObject(" wscript.shell")

BtnCode = Wshell.Popup(" test",1," testing")

1 个答案:

答案 0 :(得分:1)

我担心弹出窗口无法做到这一点。 您可以使用Internet Explorer作为UI。

Set oIE = CreateObject("InternetExplorer.Application") 

With oIE 
  .navigate("about:blank") 
  .Document.Title = "Countdown" & string(100, chrb(160)) 
  .resizable=0 
  .height=200 
  .width=100 
  .menubar=0 
  .toolbar=0 
  .statusBar=0 
  .visible=1 
End With 

' wait for page to load 
Do while oIE.Busy 
  wscript.sleep 50 
Loop 

' prepare document body 
oIE.document.body.innerHTML = "<div id=""countdown"" style=""font: 36pt sans-serif;text-align:center;""></div>" 
oIE.document.all.countdown.innerText= "test message"
'the parameters is in miliseconds, so here the message is shown for half a second
wscript.sleep 500
oIE.quit