Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can script close a message box window after a few seconds? 1

Status
Not open for further replies.

dbMark

Programmer
Apr 10, 2003
1,515
US
I have a login script where I want the user to be notified whether login was successful or not. Since 99% of the time the user logs in just fine, I'd like the success message box to display for a few seconds then close automatically without any user interaction. So far I can't see a way to set a timer or timed window on the message box window. Is there another way to close a message window without clicking on it?

Here's what the 2 message boxes look like.

Code:
MsgBox "Welcome!", 64, "Login Successful"

MsgBox "Error #" & cStr(Err.Number) & " " & Err.Description, 48, "Login Failed"
 
After some additional searching I found these threads which may help:

thread329-372772 Closing an active window (no replies)

thread329-713266 WScript.Sleep 5000 'pause in milliseconds
 
Hello dbMark,

This should do.
Code:
createobject("wscript.shell").popup "Welcome!", 5, "Login Successful", 64
regards - tsuji

ps. dbMark, take a look at my posting in 329-786428 with a sample script which might help you in one of the topic you did a good research previously.
 
tsuji,

That's exactly what I needed, a brief message that goes away after a few moments. I could see that VBScript's msgBox() had no timer, but I wasn't familiar enough to know where to look.

I also tested a series of those popups one after the other. I was curious whether they'd all pop up at once and close at once, but they don't, they go in sequence just nicely.

A question: Since I'm not creating an object variable, am I correct that there is nothing to close, such as that object, at the end of the script?
Code:
' Countdown message
createobject("wscript.shell").popup "3...", 1, "Login Successful", 64
createobject("wscript.shell").popup "2...", 1, "Login Successful", 64
createobject("wscript.shell").popup "1...", 1, "Login Successful", 64

As for thread329-786428, I took a look at the code, thanks for helping.

A star is granted! (I don't mind asking strange, seldom-asked questions since I figure it creates a history others can search in the years to come.)

dbMark
 
dbMark,

Thanks. Glad you like it.

It is done synchronously. The control is not surrendered until time's up or button pressed.

Yes, no need to free up the object in this construction, in case memory is an issue of worry.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top