Timed MsgBox



As I'm working also with test automation sometimes I would like to have a timed Popup. With this example we'll create a popup, with a message inside, that will close automatically.


MsgBox function don't have a parameter that tell a time it must closed. To achieve this task we have to use "WScript.Shell" object. Let's see how:


Wscript.Shell object is very powerful in vbscript. It is used to do several things, also create a more complex Popup than the msgbox. Here an example to show for 3 seconds a Popup with a message and the "information" icon:



'******************* MAIN **********************



Dim MyShell


'istance Wscript.Shell object

set MyShell = CreateObject("Wscript.Shell")


'once I create the object I can use its methods also the .Popup method

'Popup Method Arguments:

' - Text (mandatory - also an empty "" string)

' - Number of Seconds of Wait before the Window Close

' - DialogBox Title

' - Type: integer that means which type of button use and wich icon

'           must be shown

'I suggest to see the details here 


'Let's write this message "This window will close after 3 seconds" that will close after 3 seconds


MyShell.Popup "This window will close after 3 seconds", 3, "This is the dialogbox title", 64


'Destroy the object.

'This operation must be done to clean the memory

set MyShell = Nothing



'***********     FINE MAIN     **********************





Pag: <    >    >>