AutoClosingMsgBox.vbs |
' This and other code samples can be found at www.RichSchreiber.com
Option Explicit
Dim oShell, intButton, strMessage
Set oShell = CreateObject("WScript.Shell")
oShell.Popup "Message Body",5,"Title",64
' oShell.Popup strMessage [,intSecondsToWait] [,strTitle] [,intType]
intButton = oShell.Popup ("Click a button to proceed.", 5, , 2 + 48)
select case intButton
case -1
strMessage = "You did not click any button within the 5 seconds allotted."
case 3
strMessage = "You clicked the Abort button."
case 4
strMessage = "You clicked the Retry button."
case 5
strMessage = "You clicked the Ignore button."
end select
oShell.Popup strMessage,10,"Click Result",64
wscript.quit
The strMessage, intSecondsToWait, and strTitle are obvious. The intType can be any of the following or combinations of them.
Button Layout0 = OK
1 = OK, Cancel 2 = Abort, Ignore, Retry 3 = Yes, No, Cancel 4 = Yes, No 5 = Retry, Cancel |
Icons16 = Critical
32 = Question 48 = Exclamation 64 = Information |
The button values and icon values can be added together for composite effect. For example intType of 2 + 48 means a message box with the 'Exclamation' icon, and 'Abort, Ignore, Retry ' buttons.
The Popup method can also return the button which the user clicked to dismiss the pop-up message box.
The Popup method can also return the button which the user clicked to dismiss the pop-up message box.
intReturnValue1 =
2 = 3 = 4 = 5 = 6 = 7 = -1 = |
Button ClickedOK
Cancel Abort Retry Ignore Yes No None, message box was dismissed automatically (timeout) |