Login | |
|
 |
RE: Progress Bar without using IE - 7/22/2005 8:03:48 AM
|
|
 |
|
| |
Snipah
Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
|
You can also use the Popup function: Const NoButtonClicked = -1 intSecondsToWait = 10 strText = "This Popup window will automatically close in " & intSecondsToWait & " seconds..." strTitle = "Popup Example" intType = vbOKCancel + vbInformation ' Values obtained from VBScript's MsgBox Constants. Set oShell = CreateObject("WScript.Shell") intButton = oShell.Popup(strText, intSecondsToWait, strTitle, intType)
_____________________________
For more information, please see the "Read me First" topic. http://www.visualbasicscript.com
|
|
| |
|
|
|
 |
RE: Progress Bar without using IE - 7/22/2005 8:14:58 AM
|
|
 |
|
| |
Country73
Posts: 712
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
|
Here's another variation for what Snipah has already posted. call popup(10) sub popup (waittime) sTitle="Removing... Estimated time needed " & waittime & " seconds." sMsg="To check time remaining, press OK." & vbcrlf set wshshell=createobject("wscript.shell") remaintime=waittime : starttime=now do while MyButton<>-1 and remaintime>0 MyButton = WshShell.Popup(sMsg, remaintime, sTitle, 64-0) remaintime=waittime-datediff("s",starttime,now) if MyButton<>-1 then sMsg=sMsg & vbcrlf & "Time remaining : "& remaintime & " seconds." end if loop sTitle="Removal is complete." sMsg="Thank you for your patience!" MyButton = wshshell.popup(sMsg, 2, sTitle, 64-0) set wshshell=nothing end sub
|
|
| |
|
|
|
 |
RE: Progress Bar without using IE - 7/24/2005 9:15:01 AM
|
|
 |
|
| |
Fredledingue
Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
|
Here is a progressbar that I have created. 1/ Create a file named ProgressBar.log 2/ Copy-paste the following code into ProgressBarFast.vbs quote:
'---------by Fredledingue--------- '--------set constants-------- Const ForReading = 1, ForWriting = 2, ForAppending = 3 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 Const OPEN_FILE_FOR_APPENDING = 8 Set fso = CreateObject("Scripting.fileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell") Title = "Progress" '--------read from file----------- Set f = fso.GetFile("ProgressBar.log") Set ts = f.OpenAsTextStream(ForReading, Tristatefalse) Execute ts.ReadAll ts.Close d = FormatNumber( Done / (sNum/100) +1 ,0,0,0,0) Msg1 = String(d, "]") & String(100 - d, ".") Msg2 = Done & "/" & sNum Msg3 = "To stop the progressbar clic ""Cancel""" & VbCrlf & "Attention: This will not stop the process." Do Until Done >= sNum BtnCode = WshShell.Popup(Msg1 & VbCrlf & Msg2 & VbCrlf & Msg3, 1, Title, 1) '------to change the refresh speed: change the number after "Msg3," Select Case BtnCode case 1 MsgBox "The progress bar will be back in one minutes.",,Title '------ok WScript.Sleep 60000 case 2 MsgBox " " & _ VbCrlf & "Attention: The progressbar will disapear but the script process will continue." & _ VbCrlf & _ VbCrlf & "To stop the script process:" & _ VbCrlf & VbTab & "-Clic here on ""Ok"", then..." & _ VbCrlf & VbTab & "-Type Ctrl+Alt+Del." & _ VbCrlf & VbTab & "-Select ""Wscript"" in the task list. If several you will need to stop them all." & _ VbCrlf & VbTab & "-Clic ""End Task""." & _ VbCrlf & VbTab & "-Clic ""End Task"" one more time" & _ VbCrlf & VbTab & "-Repeat this operation until all the ""Wscript"" tasks have been terminated. ",,Title wscript.quit End Select Set ts = f.OpenAsTextStream(ForReading, Tristatefalse) Execute ts.ReadAll ts.Close d = FormatNumber( Done / (sNum/100) +1 ,0,0,0,0) If d <= 100 Then Msg1 = String(d, "]") & String(100 - d, ".") End If Msg2 = Done & "/" & sNum '-----------check if progressing-------- Done1 = Done2 Done2 = Done If Done2 > Done1 Then Idletime = 0 Else Idletime = Idletime +1 If Idletime = 45 Then WshShell.Popup "Program not responding!",, Title, 0 + 16 End If End If Loop 3/ Take inspiration from this script demo to include the codeline necessary to run the progress bar into your script quote:
'---By Fredledingue------- '--------set constants-------- Const ForReading = 1, ForWriting = 2, ForAppending = 3 Set WshShell = WScript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") '---------number of items------------ sNum = 300 '------you will need to count how many items to process before '--------write to progressbar report--------- Set Progress = fso.OpenTextFile("ProgressBar.log", ForWriting) Progress.WriteLine "sNum = " & sNum Progress.WriteLine "Done = 0 _" Progress.Write "+0" WshShell.Run "ProgressBarFast.vbs" WScript.Sleep 250 '---------------------------------------------------- For i=0 To sNum WScript.Sleep 50 '-------replace "sleep" by some operation here Progress.Write "+1" Next Progress.Close MsgBox "ok",,"Test" '------------end of script sample--------- ProgressBarFast.vbs or ProgressBar.vbs , as well as ProgressBar.log must be included in the same directory as your script.
_____________________________
Fred
|
|
| |
|
|
|
 |
RE: Progress Bar without using IE - 7/25/2005 1:50:21 AM
|
|
 |
|
| |
mbouchard
Posts: 1856
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
|
You can also use AutoIT from www.hiddensoft.com which has a progressbar command. AutoIT is a scripting language that you can compile. I have created a couple scripts in AutoIT that indicate Progress. If you want to go this route let me know and I can post what I have. Edited, corrected link.
< Message edited by mbouchard -- 7/25/2005 2:16:42 AM >
_____________________________
Mike For useful Scripting links see the Read Me First stickey! Always remember Search is your friend.
|
|
| |
|
|
|
 |
RE: Progress Bar without using IE - 9/1/2005 6:34:10 AM
|
|
 |
|
| |
Fredledingue
Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
|
This is a way (non tested) to calculate the remaining time TimeElapsed = DateDiff("n", StartTime , Now()) TotalEstimatedTime = (TimeElapsed/Done)*NumberOfItems TimeRemaining = TotalEstimatedTime - TimeElapsed You can add this code to my progressbar script. In my progress bar script replace "NumberOfItems" by "sNum". I will publish a new version including this code and other stuffs in the "Post a code" forum as soon as I have tested it.
_____________________________
Fred
|
|
| |
|
|
|
 |
RE: Progress Bar without using IE - 12/9/2005 7:58:51 AM
|
|
 |
|
| |
kirrilian
Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
|
Sorry to dig up an old post but I figured out a way to do this when using cscript, I put this in my loops i want to check the progress of, dim progress 'clear the variable before starting progress = "" for each blah in blabbity progress = progress & "." 'WScript.stdout.write doesnt add a newline so its a continuous line of dots WScript.StdOut.Write progress next make sure youre using cscript or you'll be clicking ok alot lol
< Message edited by kirrilian -- 12/9/2005 8:00:02 AM >
_____________________________
Have you searched here ? VBScript Fundamentals My Site
|
|
| |
|
|
|
 |
RE: Progress Bar without using IE - 12/11/2005 2:58:30 AM
|
|
 |
|
| |
Cybex
Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
|
Just by showing a sequence of dots does not tell anything about the overall progress, other than actions are taking place. I have no idea if I am waiting to see ten dots or one hundred. How would I extrapolate the progress from this? Cybex Edited for typo...
_____________________________
Common sense is not so common.
|
|
| |
|
|
|
 |
RE: Progress Bar without using IE - 12/11/2005 10:46:46 AM
|
|
 |
|
| |
kirrilian
Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
|
sorry i misunderstood, i thought progress was showing that actions are taking place. granted it isnt showing percent complete or anything, but this was meant to be a simple way of showing a user that "something" is happening. oftentimes there is no way to know what the total progress is going to be so i think its better to show that something is going on rather than just sitting there looking at a flashing prompt lol
_____________________________
Have you searched here ? VBScript Fundamentals My Site
|
|
| |
|
|
|
|
|