![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3
![]() |
VBScript - Timed Message Box?
I am searching around on google and will continue to do so till i figure this out, but figured i'de post here as well.
Is there an easy way to script a MsgBox that is timed. Once the time is over, it will close itself. From what i've found i can do this through VB.net, but I can't find it for Script yet. Any suggestions would be greatly appreciated. I do know how to do the Msgbox command to get one to come up, but i can only do it with required user interaction. This is what I don't want.
__________________
_Marshall_ "America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt." |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
This is very similar to what you need to do, only instead of opening a msgbox when the time is up, open it at the beginning and close it at the end.
'*************************************************************
'This program makes use of a recursive procedure HandleTime.
'The important aspects of the code are "Status" and "setTimeOut".
'Status is an attribute of the Window object in VBScript and is used to
'change the status message of the active window.
'setTimeOut is a VBScript function that tells after how much time the timer
'would stop and accordingly it calls a function passed into it to take some
'action when the time is up.
'This procedure calls its self after every 1 sec (I have taken 1sec = 950ms
' here) and accordingly the variables hr, min and sec are decremented.
'*************************************************************
Sub HandleTime
if hr=0 and min=0 and sec=0 then
EndTime
'**When hr, min and sec are all 0, this means that the time is up
'**and EndTime procedure is 'called.
elseif min>=0 and sec>0 then
sec=sec-1
status=hr & ":" & min & ":" & sec
'**Whenever the second changes the Status of the window has to
'be changed.
intTimerID=setTimeOut("HandleTime",950, "VBScript")
'**setTimeOut function returns a unique timer id that is used to
'keep track of the time.
'**When the time is up the timer id is destroyed automatically.
elseif min>0 and sec=0 then
min=min-1
sec=59
status=hr & ":" & min & ":" & sec
intTimerID=setTimeOut("HandleTime",950, "VBScript")
elseif hr>=0 and min=0 then
hr=hr-1
min=59
sec=59
status=hr & ":" & min & ":" & sec
intTimerID=setTimeOut("HandleTime",950, "VBScript")
end if
End Sub
Sub EndTime
clearTimeOut intTimerID
'**clearTimeOut is a built in procedure of VBScript which is used to
'**clear and destroy the timer id explicitly
status = "Your Time Ended"
'**When the time ends the status bar displays this message.
msgbox "Time Up"
End Subtaken from: http://www.codeproject.com/asp/webtimer.asp
__________________
I have never let my schooling interfere with my education. -Mark Twain- Xbox live gamertag: melbolt |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3
![]() |
Melbolt, thank you very much. I'll go ahead and mess with that till I understand it completely, then modify to work the way I need! *thumbs up*
__________________
_Marshall_ "America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt." |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3
![]() |
After reading through the ElseIf and making sense of it all i really like how they use it counts down. My problem is, I want the box to close automatically after 6 seconds without user interaction. More like a, "ok, things are working" and gone. I might be stabbing in the dark at something that doesn't exist. Also, i am probably not experienced enough to know all the internal functions or how to properly search them for the right key words. Once again, thank you for all the help.
__________________
_Marshall_ "America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt." |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3
![]() |
Ok, found a link the directs me to using the PopUp method. This is bassically what it's saying to do.
Const wshYes = 6
Const wshNo = 7
Const wshYesNoDialog = 4
Const wshQuestionMark = 32
Set objShell = CreateObject("Wscript.Shell")
intReturn = objShell.Popup("Do you want to delete this file?", _
10, "Delete File", wshYesNoDialog + wshQuestionMark)
If intReturn = wshYes Then
Wscript.Echo "You clicked the Yes button."
ElseIf intReturn = wshNo Then
Wscript.Echo "You clicked the No button."
Else
Wscript.Echo "The popup timed out."
End IfThe rest of the information can be located at Linky!
__________________
_Marshall_ "America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|