Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Pure Vb script progress or status bar

Reply
 
Old 08-05-2009   #1 (permalink)
James


 
 

Pure Vb script progress or status bar

I am looking for something really simple. Everything I have found on the
web is using HTA or something really complicated. I wrote a script to copy
files and folders to a network drive for an end user. I want a message box
to come up with no buttons at all that simply show the progress. I don't
mind if the message box simply updates itsself using a loop and says
something like "step 1 complete" then updates when the next folder is copied
up to say "step 2 complete". But, if there is a way for it to hook into
windows and get the actual time calculation for the copy and display it,
that would be even better. Any help would be great.

James



My System SpecsSystem Spec
Old 08-05-2009   #2 (permalink)
Eric


 
 

Re: Pure Vb script progress or status bar


"James" <donotreply@xxxxxx> wrote in message
news:uMwsFIfFKHA.3948@xxxxxx
Quote:

>I am looking for something really simple. Everything I have found on the
>web is using HTA or something really complicated. I wrote a script to copy
>files and folders to a network drive for an end user. I want a message box
>to come up with no buttons at all that simply show the progress. I don't
>mind if the message box simply updates itsself using a loop and says
>something like "step 1 complete" then updates when the next folder is
>copied up to say "step 2 complete". But, if there is a way for it to hook
>into windows and get the actual time calculation for the copy and display
>it, that would be even better. Any help would be great.
>
> James
I'm sure this does more than you need. I don't remember where I got it. I
think the code to do what you want to do is in here somewhere.

'---------------------
'
' Filename justwait.vbs
' Author Andreas Schneider
'
' Status Final 1.0
'
' Prerequisite Windows Scripting Host
' IE 6
'
' Abstract Displays a ping/pong progress bar
'
' History
' 04/07/2003 0.1
'
'---------------------

'Option Explicit

'---------------------
'
' global const
'
'---------------------

Const conBarSpeed=80
Const conForcedTimeOut=10000

'---------------------
'
' global vars
'
'---------------------

Dim objIE
Dim objProgressBar
Dim objTextLine1
Dim objTextLine2
Dim objQuitFlag


'---------------------
'
' Call Sample Function
'
'---------------------

Sample

'---------------------
'
' Function Sample
'
' Abstract Sample Entry Point
'
' Parameters
'
' Return values
'
' Revision
'
'---------------------

Public Sub Sample()

Dim intCount

StartIE "Ping/Pong Progress Bar"

SetLine1 "Progress Bar Line 1"

For intCount=1 To 10000

If IsQuit()=True Then

Exit For
End If

SetLine2 CStr(intCount)
Next

CloseIE

MsgBox "End of Sample"

End Sub

'---------------------
'
' Function StartIE
'
' Abstract Launch IE Dialog Box and Progress bar
'
' Parameters Titel of the box
'
' Return values
'
' Revision
'
'---------------------


Private Sub StartIE(strTitel)

Dim objDocument
Dim objWshShell

Set objIE = CreateObject("InternetExplorer.Application")

objIE.height = 230
objIE.width = 400

objIE.menubar = False
objIE.toolbar = false
objIE.statusbar = false
objIE.addressbar = false
objIE.resizable = False

objIE.navigate ("about:blank")

' wait till ie is loaded
While (objIE.busy)
wend

set objDocument = objIE.document

' setup the dialog box
WriteHtmlToDialog objDocument, strTitel

' with ie/html loaded, define assorted objects...
set objTextLine1 = objIE.document.all("txtMilestone")
set objTextLine2 = objIE.document.all("txtRemarks")
Set objProgressBar = objIE.document.all("pbText")
set objQuitFlag = objIE.document.Secret.pubFlag

objTextLine1.innerTEXT = ""
objTextLine2.innerTEXT = ""

' objIE.document.body.innerHTML = "Building Document..." + "<br>load
time= " + n
objIE.visible = True

' set focus to ie
Set objWSHShell = WScript.CreateObject("WScript.Shell")
objWshShell.AppActivate("Microsoft Internet Explorer")

End Sub

'---------------------
'
' Function CloseIE
'
' Abstract Close the IE Browser Windows
'
' Parameters
'
' Return values
'
' Revision
'
'---------------------

Private Function CloseIE()

On Error Resume Next

objIE.quit
End Function

'---------------------
'
' Function SetLine1
'
' Abstract Set Text Line in the Progress Bar Dialog Box
'
' Parameters Progress Text
'
' Return values
'
' Revision
'
'---------------------

Private sub SetLine1(sNewText)

On Error Resume Next

objTextLine1.innerTEXT = sNewText
End Sub

'---------------------
'
' Function SetLine2
'
' Abstract Set Text Line in the Progress Bar Dialog Box
'
' Parameters Progress Text
'
' Return values
'
' Revision
'
'---------------------

Private sub SetLine2(sNewText)

On Error Resume Next

objTextLine2.innerTEXT = sNewText
End Sub


'---------------------
'
' Function IsQuit
'
' Abstract Checks if the quit button was pressed
'
' Parameters Progress Text
'
' Return values
'
' Revision
'
'---------------------

Private function IsQuit()

On Error Resume Next

IsQuit=True

If objQuitFlag.Value<>"quit" Then

IsQuit=False
End If

End function

'---------------------
'
' Function WriteHtmlToDialog
'
' Abstract Set HTML Text for the IE Dialog box
'
' Parameters IE Document Object, Title Text
'
' Return values
'
' Revision
'
'---------------------

Private Sub WriteHtmlToDialog(objDocument, strTitel)

objDocument.Open

objDocument.Writeln "<title>" & strTitel & "</title> "

objDocument.Writeln "<style>"
objDocument.Writeln " BODY {background: Silver} BODY {
overflow:hidden }"
objDocument.Writeln " P.txtStyle {color: Navy; font-family: Verdana; " _
& " font-size: 10pt; font-weight: bold; margin-left: 10px } "

objDocument.Writeln " input.pbStyle {color: Navy; font-family:
Wingdings; " _
& " font-size: 10pt; background: Silver; height: 20px; " _
& " width: 340px } "
objDocument.Writeln "</style>"

objDocument.Writeln "<div id=""objProgress"" class=""Outer""></div>"

' write out text lines...
objDocument.Writeln "<P id=txtMilestone class='txtStyle'
style='margin-left: 10px'> </P>"
objDocument.Writeln "<P id=txtRemarks class='txtStyle'
style='margin-left: 10px' ></P>"
objDocument.Writeln "<CENTER>"

' write progbar
objDocument.Writeln "<input type='text' id='pbText' class='pbStyle'
value='' >"
objDocument.Writeln "<br><br>" ' space down a little

' write cancel button...
objDocument.Writeln "<input type='button' value='Cancel' " _
& " onclick='SetReturnFlag(""quit"")' >"
objDocument.Writeln "</CENTER>"

' write hidden object...
objDocument.Writeln "<form name='secret' >" _
& " <input type='hidden' name='pubFlag' value='run' >" _
& "</form>"

objDocument.Writeln "<SCRIPT LANGUAGE='VBScript' >"

' write "local script" to handle cmdCancel_Click event...
objDocument.Writeln "Sub SetReturnFlag(sFlag)"
objDocument.Writeln " secret.pubFlag.Value = sFlag"
objDocument.Writeln " txtMileStone.style.color = ""Red"" "
objDocument.Writeln " txtRemarks.style.color = ""Red"" "
objDocument.Writeln "End Sub"

' progress bar
objDocument.Writeln "Function PctComplete(nPct)"
objDocument.Writeln "pbText.Value = String(nPct,"" "") &
String(4,""n"")"
objDocument.Writeln "End Function"

' calc progress bar and direction
objDocument.Writeln "Sub UpdateProgress()"
objDocument.Writeln "Dim intStep"
objDocument.Writeln "Dim intDirection"

objDocument.Writeln "If (IsNull(objProgress.getAttribute(""Step"")) =
True) Then"
objDocument.Writeln "intStep = 0"
objDocument.Writeln "Else"
objDocument.Writeln "intStep = objProgress.Step"
objDocument.Writeln "End If"

objDocument.Writeln "if
(IsNull(objProgress.GetAttribute(""Direction""))=True) Then"
objDocument.Writeln "intDirection = 0"
objDocument.Writeln "Else"
objDocument.Writeln "intDirection = objProgress.Direction"
objDocument.Writeln "End If"

objDocument.Writeln "if intDirection=0 then"
objDocument.Writeln "intStep = intStep + 1"
objDocument.Writeln "else"
objDocument.Writeln "intStep = intStep - 1"
objDocument.Writeln "end if"

objDocument.Writeln "Call PctComplete(intStep)"

objDocument.Writeln "if intStep>=23 then"
objDocument.Writeln "intDirection=1"
objDocument.Writeln "end if"
objDocument.Writeln "if intStep<=0 then"
objDocument.Writeln "intDirection=0"
objDocument.Writeln "end if"

objDocument.Writeln "objProgress.SetAttribute ""Step"", intStep"
objDocument.Writeln "objProgress.SetAttribute ""Direction"",
intDirection"

objDocument.Writeln "Window.setTimeout GetRef(""UpdateProgress""), " &
conBarSpeed
objDocument.Writeln "End Sub"

' timeout function
objDocument.Writeln "Sub DialogHardTimeout()"
objDocument.Writeln "SetReturnFlag(""quit"")"
objDocument.Writeln "End sub"

objDocument.Writeln "Sub Window_OnLoad()"
objDocument.Writeln "theleft = (screen.availWidth -
document.body.clientWidth) / 2"
objDocument.Writeln "thetop = (screen.availHeight -
document.body.clientHeight) / 2"
objDocument.Writeln "window.moveTo theleft,thetop"
objDocument.Writeln "Window.setTimeout GetRef(""UpdateProgress""), " &
conBarSpeed
objDocument.Writeln "Window.setTimeout GetRef(""DialogHardTimeout""), "
& conForcedTimeOut
objDocument.Writeln "End Sub"

objDocument.Writeln "</SCRIPT>"

objDocument.Close

End Sub


My System SpecsSystem Spec
Old 08-05-2009   #3 (permalink)
James


 
 

Re: Pure Vb script progress or status bar

I got a lot of errors when I copied the code, saved it as a sample.vbs and
tried to run it. I commented out the lines giving the errors and I only got
the message box at the end...no status or progress indicator...

James

"Eric" <someone@xxxxxx> wrote in message
news:eIlVVYfFKHA.3816@xxxxxx
Quote:

>
> "James" <donotreply@xxxxxx> wrote in message
> news:uMwsFIfFKHA.3948@xxxxxx
Quote:

>>I am looking for something really simple. Everything I have found on the
>>web is using HTA or something really complicated. I wrote a script to
>>copy files and folders to a network drive for an end user. I want a
>>message box to come up with no buttons at all that simply show the
>>progress. I don't mind if the message box simply updates itsself using a
>>loop and says something like "step 1 complete" then updates when the next
>>folder is copied up to say "step 2 complete". But, if there is a way for
>>it to hook into windows and get the actual time calculation for the copy
>>and display it, that would be even better. Any help would be great.
>>
>> James
> I'm sure this does more than you need. I don't remember where I got it.
> I think the code to do what you want to do is in here somewhere.
>
> '---------------------
> '
> ' Filename justwait.vbs
> ' Author Andreas Schneider
> '
> ' Status Final 1.0
> '
> ' Prerequisite Windows Scripting Host
> ' IE 6
> '
> ' Abstract Displays a ping/pong progress bar
> '
> ' History
> ' 04/07/2003 0.1
> '
> '---------------------
>
> 'Option Explicit
>
> '---------------------
> '
> ' global const
> '
> '---------------------
>
> Const conBarSpeed=80
> Const conForcedTimeOut=10000
>
> '---------------------
> '
> ' global vars
> '
> '---------------------
>
> Dim objIE
> Dim objProgressBar
> Dim objTextLine1
> Dim objTextLine2
> Dim objQuitFlag
>
>
> '---------------------
> '
> ' Call Sample Function
> '
> '---------------------
>
> Sample
>
> '---------------------
> '
> ' Function Sample
> '
> ' Abstract Sample Entry Point
> '
> ' Parameters
> '
> ' Return values
> '
> ' Revision
> '
> '---------------------
>
> Public Sub Sample()
>
> Dim intCount
>
> StartIE "Ping/Pong Progress Bar"
>
> SetLine1 "Progress Bar Line 1"
>
> For intCount=1 To 10000
>
> If IsQuit()=True Then
>
> Exit For
> End If
>
> SetLine2 CStr(intCount)
> Next
>
> CloseIE
>
> MsgBox "End of Sample"
>
> End Sub
>
> '---------------------
> '
> ' Function StartIE
> '
> ' Abstract Launch IE Dialog Box and Progress bar
> '
> ' Parameters Titel of the box
> '
> ' Return values
> '
> ' Revision
> '
> '---------------------
>
>
> Private Sub StartIE(strTitel)
>
> Dim objDocument
> Dim objWshShell
>
> Set objIE = CreateObject("InternetExplorer.Application")
>
> objIE.height = 230
> objIE.width = 400
>
> objIE.menubar = False
> objIE.toolbar = false
> objIE.statusbar = false
> objIE.addressbar = false
> objIE.resizable = False
>
> objIE.navigate ("about:blank")
>
> ' wait till ie is loaded
> While (objIE.busy)
> wend
>
> set objDocument = objIE.document
>
> ' setup the dialog box
> WriteHtmlToDialog objDocument, strTitel
>
> ' with ie/html loaded, define assorted objects...
> set objTextLine1 = objIE.document.all("txtMilestone")
> set objTextLine2 = objIE.document.all("txtRemarks")
> Set objProgressBar = objIE.document.all("pbText")
> set objQuitFlag = objIE.document.Secret.pubFlag
>
> objTextLine1.innerTEXT = ""
> objTextLine2.innerTEXT = ""
>
> ' objIE.document.body.innerHTML = "Building Document..." + "<br>load
> time= " + n
> objIE.visible = True
>
> ' set focus to ie
> Set objWSHShell = WScript.CreateObject("WScript.Shell")
> objWshShell.AppActivate("Microsoft Internet Explorer")
>
> End Sub
>
> '---------------------
> '
> ' Function CloseIE
> '
> ' Abstract Close the IE Browser Windows
> '
> ' Parameters
> '
> ' Return values
> '
> ' Revision
> '
> '---------------------
>
> Private Function CloseIE()
>
> On Error Resume Next
>
> objIE.quit
> End Function
>
> '---------------------
> '
> ' Function SetLine1
> '
> ' Abstract Set Text Line in the Progress Bar Dialog Box
> '
> ' Parameters Progress Text
> '
> ' Return values
> '
> ' Revision
> '
> '---------------------
>
> Private sub SetLine1(sNewText)
>
> On Error Resume Next
>
> objTextLine1.innerTEXT = sNewText
> End Sub
>
> '---------------------
> '
> ' Function SetLine2
> '
> ' Abstract Set Text Line in the Progress Bar Dialog Box
> '
> ' Parameters Progress Text
> '
> ' Return values
> '
> ' Revision
> '
> '---------------------
>
> Private sub SetLine2(sNewText)
>
> On Error Resume Next
>
> objTextLine2.innerTEXT = sNewText
> End Sub
>
>
> '---------------------
> '
> ' Function IsQuit
> '
> ' Abstract Checks if the quit button was pressed
> '
> ' Parameters Progress Text
> '
> ' Return values
> '
> ' Revision
> '
> '---------------------
>
> Private function IsQuit()
>
> On Error Resume Next
>
> IsQuit=True
>
> If objQuitFlag.Value<>"quit" Then
>
> IsQuit=False
> End If
>
> End function
>
> '---------------------
> '
> ' Function WriteHtmlToDialog
> '
> ' Abstract Set HTML Text for the IE Dialog box
> '
> ' Parameters IE Document Object, Title Text
> '
> ' Return values
> '
> ' Revision
> '
> '---------------------
>
> Private Sub WriteHtmlToDialog(objDocument, strTitel)
>
> objDocument.Open
>
> objDocument.Writeln "<title>" & strTitel & "</title> "
>
> objDocument.Writeln "<style>"
> objDocument.Writeln " BODY {background: Silver} BODY {
> overflow:hidden }"
> objDocument.Writeln " P.txtStyle {color: Navy; font-family: Verdana; "
> _
> & " font-size: 10pt; font-weight: bold; margin-left: 10px } "
>
> objDocument.Writeln " input.pbStyle {color: Navy; font-family:
> Wingdings; " _
> & " font-size: 10pt; background: Silver; height: 20px; " _
> & " width: 340px } "
> objDocument.Writeln "</style>"
>
> objDocument.Writeln "<div id=""objProgress"" class=""Outer""></div>"
>
> ' write out text lines...
> objDocument.Writeln "<P id=txtMilestone class='txtStyle'
> style='margin-left: 10px'> </P>"
> objDocument.Writeln "<P id=txtRemarks class='txtStyle'
> style='margin-left: 10px' ></P>"
> objDocument.Writeln "<CENTER>"
>
> ' write progbar
> objDocument.Writeln "<input type='text' id='pbText' class='pbStyle'
> value='' >"
> objDocument.Writeln "<br><br>" ' space down a little
>
> ' write cancel button...
> objDocument.Writeln "<input type='button' value='Cancel' " _
> & " onclick='SetReturnFlag(""quit"")' >"
> objDocument.Writeln "</CENTER>"
>
> ' write hidden object...
> objDocument.Writeln "<form name='secret' >" _
> & " <input type='hidden' name='pubFlag' value='run' >" _
> & "</form>"
>
> objDocument.Writeln "<SCRIPT LANGUAGE='VBScript' >"
>
> ' write "local script" to handle cmdCancel_Click event...
> objDocument.Writeln "Sub SetReturnFlag(sFlag)"
> objDocument.Writeln " secret.pubFlag.Value = sFlag"
> objDocument.Writeln " txtMileStone.style.color = ""Red"" "
> objDocument.Writeln " txtRemarks.style.color = ""Red"" "
> objDocument.Writeln "End Sub"
>
> ' progress bar
> objDocument.Writeln "Function PctComplete(nPct)"
> objDocument.Writeln "pbText.Value = String(nPct,"" "") &
> String(4,""n"")"
> objDocument.Writeln "End Function"
>
> ' calc progress bar and direction
> objDocument.Writeln "Sub UpdateProgress()"
> objDocument.Writeln "Dim intStep"
> objDocument.Writeln "Dim intDirection"
>
> objDocument.Writeln "If (IsNull(objProgress.getAttribute(""Step"")) =
> True) Then"
> objDocument.Writeln "intStep = 0"
> objDocument.Writeln "Else"
> objDocument.Writeln "intStep = objProgress.Step"
> objDocument.Writeln "End If"
>
> objDocument.Writeln "if
> (IsNull(objProgress.GetAttribute(""Direction""))=True) Then"
> objDocument.Writeln "intDirection = 0"
> objDocument.Writeln "Else"
> objDocument.Writeln "intDirection = objProgress.Direction"
> objDocument.Writeln "End If"
>
> objDocument.Writeln "if intDirection=0 then"
> objDocument.Writeln "intStep = intStep + 1"
> objDocument.Writeln "else"
> objDocument.Writeln "intStep = intStep - 1"
> objDocument.Writeln "end if"
>
> objDocument.Writeln "Call PctComplete(intStep)"
>
> objDocument.Writeln "if intStep>=23 then"
> objDocument.Writeln "intDirection=1"
> objDocument.Writeln "end if"
> objDocument.Writeln "if intStep<=0 then"
> objDocument.Writeln "intDirection=0"
> objDocument.Writeln "end if"
>
> objDocument.Writeln "objProgress.SetAttribute ""Step"", intStep"
> objDocument.Writeln "objProgress.SetAttribute ""Direction"",
> intDirection"
>
> objDocument.Writeln "Window.setTimeout GetRef(""UpdateProgress""), " &
> conBarSpeed
> objDocument.Writeln "End Sub"
>
> ' timeout function
> objDocument.Writeln "Sub DialogHardTimeout()"
> objDocument.Writeln "SetReturnFlag(""quit"")"
> objDocument.Writeln "End sub"
>
> objDocument.Writeln "Sub Window_OnLoad()"
> objDocument.Writeln "theleft = (screen.availWidth -
> document.body.clientWidth) / 2"
> objDocument.Writeln "thetop = (screen.availHeight -
> document.body.clientHeight) / 2"
> objDocument.Writeln "window.moveTo theleft,thetop"
> objDocument.Writeln "Window.setTimeout GetRef(""UpdateProgress""), " &
> conBarSpeed
> objDocument.Writeln "Window.setTimeout GetRef(""DialogHardTimeout""), "
> & conForcedTimeOut
> objDocument.Writeln "End Sub"
>
> objDocument.Writeln "</SCRIPT>"
>
> objDocument.Close
>
> End Sub
>
>

My System SpecsSystem Spec
Old 08-05-2009   #4 (permalink)
Eric


 
 

Re: Pure Vb script progress or status bar

Check for line wrapping and remove linefeeds from lines that go together.
It runs fine on mine.

"James" <donotreply@xxxxxx> wrote in message
news:Oc4wkBgFKHA.3696@xxxxxx
Quote:

>I got a lot of errors when I copied the code, saved it as a sample.vbs and
>tried to run it. I commented out the lines giving the errors and I only
>got the message box at the end...no status or progress indicator...
>
> James
>
> "Eric" <someone@xxxxxx> wrote in message
> news:eIlVVYfFKHA.3816@xxxxxx
Quote:

>>
>> "James" <donotreply@xxxxxx> wrote in message
>> news:uMwsFIfFKHA.3948@xxxxxx
Quote:

>>>I am looking for something really simple. Everything I have found on the
>>>web is using HTA or something really complicated. I wrote a script to
>>>copy files and folders to a network drive for an end user. I want a
>>>message box to come up with no buttons at all that simply show the
>>>progress. I don't mind if the message box simply updates itsself using a
>>>loop and says something like "step 1 complete" then updates when the next
>>>folder is copied up to say "step 2 complete". But, if there is a way for
>>>it to hook into windows and get the actual time calculation for the copy
>>>and display it, that would be even better. Any help would be great.
>>>
>>> James
>> I'm sure this does more than you need. I don't remember where I got it.
>> I think the code to do what you want to do is in here somewhere.
>>
>> '---------------------
>> '
>> ' Filename justwait.vbs
>> ' Author Andreas Schneider
>> '
>> ' Status Final 1.0
>> '
>> ' Prerequisite Windows Scripting Host
>> ' IE 6
>> '
>> ' Abstract Displays a ping/pong progress bar
>> '
>> ' History
>> ' 04/07/2003 0.1
>> '
>> '---------------------
>>
>> 'Option Explicit
>>
>> '---------------------
>> '
>> ' global const
>> '
>> '---------------------
>>
>> Const conBarSpeed=80
>> Const conForcedTimeOut=10000
>>
>> '---------------------
>> '
>> ' global vars
>> '
>> '---------------------
>>
>> Dim objIE
>> Dim objProgressBar
>> Dim objTextLine1
>> Dim objTextLine2
>> Dim objQuitFlag
>>
>>
>> '---------------------
>> '
>> ' Call Sample Function
>> '
>> '---------------------
>>
>> Sample
>>
>> '---------------------
>> '
>> ' Function Sample
>> '
>> ' Abstract Sample Entry Point
>> '
>> ' Parameters
>> '
>> ' Return values
>> '
>> ' Revision
>> '
>> '---------------------
>>
>> Public Sub Sample()
>>
>> Dim intCount
>>
>> StartIE "Ping/Pong Progress Bar"
>>
>> SetLine1 "Progress Bar Line 1"
>>
>> For intCount=1 To 10000
>>
>> If IsQuit()=True Then
>>
>> Exit For
>> End If
>>
>> SetLine2 CStr(intCount)
>> Next
>>
>> CloseIE
>>
>> MsgBox "End of Sample"
>>
>> End Sub
>>
>> '---------------------
>> '
>> ' Function StartIE
>> '
>> ' Abstract Launch IE Dialog Box and Progress bar
>> '
>> ' Parameters Titel of the box
>> '
>> ' Return values
>> '
>> ' Revision
>> '
>> '---------------------
>>
>>
>> Private Sub StartIE(strTitel)
>>
>> Dim objDocument
>> Dim objWshShell
>>
>> Set objIE = CreateObject("InternetExplorer.Application")
>>
>> objIE.height = 230
>> objIE.width = 400
>>
>> objIE.menubar = False
>> objIE.toolbar = false
>> objIE.statusbar = false
>> objIE.addressbar = false
>> objIE.resizable = False
>>
>> objIE.navigate ("about:blank")
>>
>> ' wait till ie is loaded
>> While (objIE.busy)
>> wend
>>
>> set objDocument = objIE.document
>>
>> ' setup the dialog box
>> WriteHtmlToDialog objDocument, strTitel
>>
>> ' with ie/html loaded, define assorted objects...
>> set objTextLine1 = objIE.document.all("txtMilestone")
>> set objTextLine2 = objIE.document.all("txtRemarks")
>> Set objProgressBar = objIE.document.all("pbText")
>> set objQuitFlag = objIE.document.Secret.pubFlag
>>
>> objTextLine1.innerTEXT = ""
>> objTextLine2.innerTEXT = ""
>>
>> ' objIE.document.body.innerHTML = "Building Document..." + "<br>load
wrapped
Quote:
Quote:

>> time= " + n
>> objIE.visible = True
>>
>> ' set focus to ie
>> Set objWSHShell = WScript.CreateObject("WScript.Shell")
>> objWshShell.AppActivate("Microsoft Internet Explorer")
>>
>> End Sub
>>
>> '---------------------
>> '
>> ' Function CloseIE
>> '
>> ' Abstract Close the IE Browser Windows
>> '
>> ' Parameters
>> '
>> ' Return values
>> '
>> ' Revision
>> '
>> '---------------------
>>
>> Private Function CloseIE()
>>
>> On Error Resume Next
>>
>> objIE.quit
>> End Function
>>
>> '---------------------
>> '
>> ' Function SetLine1
>> '
>> ' Abstract Set Text Line in the Progress Bar Dialog Box
>> '
>> ' Parameters Progress Text
>> '
>> ' Return values
>> '
>> ' Revision
>> '
>> '---------------------
>>
>> Private sub SetLine1(sNewText)
>>
>> On Error Resume Next
>>
>> objTextLine1.innerTEXT = sNewText
>> End Sub
>>
>> '---------------------
>> '
>> ' Function SetLine2
>> '
>> ' Abstract Set Text Line in the Progress Bar Dialog Box
>> '
>> ' Parameters Progress Text
>> '
>> ' Return values
>> '
>> ' Revision
>> '
>> '---------------------
>>
>> Private sub SetLine2(sNewText)
>>
>> On Error Resume Next
>>
>> objTextLine2.innerTEXT = sNewText
>> End Sub
>>
>>
>> '---------------------
>> '
>> ' Function IsQuit
>> '
>> ' Abstract Checks if the quit button was pressed
>> '
>> ' Parameters Progress Text
>> '
>> ' Return values
>> '
>> ' Revision
>> '
>> '---------------------
>>
>> Private function IsQuit()
>>
>> On Error Resume Next
>>
>> IsQuit=True
>>
>> If objQuitFlag.Value<>"quit" Then
>>
>> IsQuit=False
>> End If
>>
>> End function
>>
>> '---------------------
>> '
>> ' Function WriteHtmlToDialog
>> '
>> ' Abstract Set HTML Text for the IE Dialog box
>> '
>> ' Parameters IE Document Object, Title Text
>> '
>> ' Return values
>> '
>> ' Revision
>> '
>> '---------------------
>>
>> Private Sub WriteHtmlToDialog(objDocument, strTitel)
>>
>> objDocument.Open
>>
>> objDocument.Writeln "<title>" & strTitel & "</title> "
>>
>> objDocument.Writeln "<style>"
>> objDocument.Writeln " BODY {background: Silver} BODY {
wrapped
Quote:
Quote:

>> overflow:hidden }"
>> objDocument.Writeln " P.txtStyle {color: Navy; font-family: Verdana; "
wrapped
Quote:
Quote:

>> _
>> & " font-size: 10pt; font-weight: bold; margin-left: 10px } "
>>
>> objDocument.Writeln " input.pbStyle {color: Navy; font-family:
wrapped
Quote:
Quote:

>> Wingdings; " _
>> & " font-size: 10pt; background: Silver; height: 20px; " _
>> & " width: 340px } "
>> objDocument.Writeln "</style>"
>>
>> objDocument.Writeln "<div id=""objProgress"" class=""Outer""></div>"
>>
>> ' write out text lines...
>> objDocument.Writeln "<P id=txtMilestone class='txtStyle'
wrapped
Quote:
Quote:

>> style='margin-left: 10px'> </P>"
>> objDocument.Writeln "<P id=txtRemarks class='txtStyle'
wrapped
Quote:
Quote:

>> style='margin-left: 10px' ></P>"
>> objDocument.Writeln "<CENTER>"
>>
>> ' write progbar
>> objDocument.Writeln "<input type='text' id='pbText' class='pbStyle'
wrapped
Quote:
Quote:

>> value='' >"
>> objDocument.Writeln "<br><br>" ' space down a little
>>
>> ' write cancel button...
>> objDocument.Writeln "<input type='button' value='Cancel' " _
>> & " onclick='SetReturnFlag(""quit"")' >"
>> objDocument.Writeln "</CENTER>"
>>
>> ' write hidden object...
>> objDocument.Writeln "<form name='secret' >" _
>> & " <input type='hidden' name='pubFlag' value='run' >" _
>> & "</form>"
>>
>> objDocument.Writeln "<SCRIPT LANGUAGE='VBScript' >"
>>
>> ' write "local script" to handle cmdCancel_Click event...
>> objDocument.Writeln "Sub SetReturnFlag(sFlag)"
>> objDocument.Writeln " secret.pubFlag.Value = sFlag"
>> objDocument.Writeln " txtMileStone.style.color = ""Red"" "
>> objDocument.Writeln " txtRemarks.style.color = ""Red"" "
>> objDocument.Writeln "End Sub"
>>
>> ' progress bar
>> objDocument.Writeln "Function PctComplete(nPct)"
>> objDocument.Writeln "pbText.Value = String(nPct,"" "") &
wrapped
Quote:
Quote:

>> String(4,""n"")"
>> objDocument.Writeln "End Function"
>>
>> ' calc progress bar and direction
>> objDocument.Writeln "Sub UpdateProgress()"
>> objDocument.Writeln "Dim intStep"
>> objDocument.Writeln "Dim intDirection"
>>
>> objDocument.Writeln "If (IsNull(objProgress.getAttribute(""Step"")) =
wrapped
Quote:
Quote:

>> True) Then"
>> objDocument.Writeln "intStep = 0"
>> objDocument.Writeln "Else"
>> objDocument.Writeln "intStep = objProgress.Step"
>> objDocument.Writeln "End If"
>>
>> objDocument.Writeln "if
wrapped
Quote:
Quote:

>> (IsNull(objProgress.GetAttribute(""Direction""))=True) Then"
>> objDocument.Writeln "intDirection = 0"
>> objDocument.Writeln "Else"
>> objDocument.Writeln "intDirection = objProgress.Direction"
>> objDocument.Writeln "End If"
>>
>> objDocument.Writeln "if intDirection=0 then"
>> objDocument.Writeln "intStep = intStep + 1"
>> objDocument.Writeln "else"
>> objDocument.Writeln "intStep = intStep - 1"
>> objDocument.Writeln "end if"
>>
>> objDocument.Writeln "Call PctComplete(intStep)"
>>
>> objDocument.Writeln "if intStep>=23 then"
>> objDocument.Writeln "intDirection=1"
>> objDocument.Writeln "end if"
>> objDocument.Writeln "if intStep<=0 then"
>> objDocument.Writeln "intDirection=0"
>> objDocument.Writeln "end if"
>>
>> objDocument.Writeln "objProgress.SetAttribute ""Step"", intStep"
>> objDocument.Writeln "objProgress.SetAttribute ""Direction"",
wrapped
Quote:
Quote:

>> intDirection"
>>
>> objDocument.Writeln "Window.setTimeout GetRef(""UpdateProgress""), " &
wrapped
Quote:
Quote:

>> conBarSpeed
>> objDocument.Writeln "End Sub"
>>
>> ' timeout function
>> objDocument.Writeln "Sub DialogHardTimeout()"
>> objDocument.Writeln "SetReturnFlag(""quit"")"
>> objDocument.Writeln "End sub"
>>
>> objDocument.Writeln "Sub Window_OnLoad()"
>> objDocument.Writeln "theleft = (screen.availWidth -
wrapped
Quote:
Quote:

>> document.body.clientWidth) / 2"
>> objDocument.Writeln "thetop = (screen.availHeight -
wrapped
Quote:
Quote:

>> document.body.clientHeight) / 2"
>> objDocument.Writeln "window.moveTo theleft,thetop"
>> objDocument.Writeln "Window.setTimeout GetRef(""UpdateProgress""), " &
wrapped
Quote:
Quote:

>> conBarSpeed
>> objDocument.Writeln "Window.setTimeout GetRef(""DialogHardTimeout""),
>> "
wrapped
Quote:
Quote:

>> & conForcedTimeOut
>> objDocument.Writeln "End Sub"
>>
>> objDocument.Writeln "</SCRIPT>"
>>
>> objDocument.Close
>>
>> End Sub
>>
>>
>
>

My System SpecsSystem Spec
Old 08-05-2009   #5 (permalink)
James


 
 

Re: Pure Vb script progress or status bar

I had to delete some extra spaces on every line that error and it works now.
It is really nice but seems like overkill for what I need. A simple msg box
that stays up the whole time my script runs and closes when it is done would
be perfect

James


"Eric" <someone@xxxxxx> wrote in message
news:%23CtGhhgFKHA.4968@xxxxxx
Quote:

> Check for line wrapping and remove linefeeds from lines that go together.
> It runs fine on mine.
>
> "James" <donotreply@xxxxxx> wrote in message
> news:Oc4wkBgFKHA.3696@xxxxxx
Quote:

>>I got a lot of errors when I copied the code, saved it as a sample.vbs and
>>tried to run it. I commented out the lines giving the errors and I only
>>got the message box at the end...no status or progress indicator...
>>
>> James
>>
>> "Eric" <someone@xxxxxx> wrote in message
>> news:eIlVVYfFKHA.3816@xxxxxx
Quote:

>>>
>>> "James" <donotreply@xxxxxx> wrote in message
>>> news:uMwsFIfFKHA.3948@xxxxxx
>>>>I am looking for something really simple. Everything I have found on
>>>>the web is using HTA or something really complicated. I wrote a script
>>>>to copy files and folders to a network drive for an end user. I want a
>>>>message box to come up with no buttons at all that simply show the
>>>>progress. I don't mind if the message box simply updates itsself using
>>>>a loop and says something like "step 1 complete" then updates when the
>>>>next folder is copied up to say "step 2 complete". But, if there is a
>>>>way for it to hook into windows and get the actual time calculation for
>>>>the copy and display it, that would be even better. Any help would be
>>>>great.
>>>>
>>>> James
>>> I'm sure this does more than you need. I don't remember where I got it.
>>> I think the code to do what you want to do is in here somewhere.
>>>
>>> '---------------------
>>> '
>>> ' Filename justwait.vbs
>>> ' Author Andreas Schneider
>>> '
>>> ' Status Final 1.0
>>> '
>>> ' Prerequisite Windows Scripting Host
>>> ' IE 6
>>> '
>>> ' Abstract Displays a ping/pong progress bar
>>> '
>>> ' History
>>> ' 04/07/2003 0.1
>>> '
>>> '---------------------
>>>
>>> 'Option Explicit
>>>
>>> '---------------------
>>> '
>>> ' global const
>>> '
>>> '---------------------
>>>
>>> Const conBarSpeed=80
>>> Const conForcedTimeOut=10000
>>>
>>> '---------------------
>>> '
>>> ' global vars
>>> '
>>> '---------------------
>>>
>>> Dim objIE
>>> Dim objProgressBar
>>> Dim objTextLine1
>>> Dim objTextLine2
>>> Dim objQuitFlag
>>>
>>>
>>> '---------------------
>>> '
>>> ' Call Sample Function
>>> '
>>> '---------------------
>>>
>>> Sample
>>>
>>> '---------------------
>>> '
>>> ' Function Sample
>>> '
>>> ' Abstract Sample Entry Point
>>> '
>>> ' Parameters
>>> '
>>> ' Return values
>>> '
>>> ' Revision
>>> '
>>> '---------------------
>>>
>>> Public Sub Sample()
>>>
>>> Dim intCount
>>>
>>> StartIE "Ping/Pong Progress Bar"
>>>
>>> SetLine1 "Progress Bar Line 1"
>>>
>>> For intCount=1 To 10000
>>>
>>> If IsQuit()=True Then
>>>
>>> Exit For
>>> End If
>>>
>>> SetLine2 CStr(intCount)
>>> Next
>>>
>>> CloseIE
>>>
>>> MsgBox "End of Sample"
>>>
>>> End Sub
>>>
>>> '---------------------
>>> '
>>> ' Function StartIE
>>> '
>>> ' Abstract Launch IE Dialog Box and Progress bar
>>> '
>>> ' Parameters Titel of the box
>>> '
>>> ' Return values
>>> '
>>> ' Revision
>>> '
>>> '---------------------
>>>
>>>
>>> Private Sub StartIE(strTitel)
>>>
>>> Dim objDocument
>>> Dim objWshShell
>>>
>>> Set objIE = CreateObject("InternetExplorer.Application")
>>>
>>> objIE.height = 230
>>> objIE.width = 400
>>>
>>> objIE.menubar = False
>>> objIE.toolbar = false
>>> objIE.statusbar = false
>>> objIE.addressbar = false
>>> objIE.resizable = False
>>>
>>> objIE.navigate ("about:blank")
>>>
>>> ' wait till ie is loaded
>>> While (objIE.busy)
>>> wend
>>>
>>> set objDocument = objIE.document
>>>
>>> ' setup the dialog box
>>> WriteHtmlToDialog objDocument, strTitel
>>>
>>> ' with ie/html loaded, define assorted objects...
>>> set objTextLine1 = objIE.document.all("txtMilestone")
>>> set objTextLine2 = objIE.document.all("txtRemarks")
>>> Set objProgressBar = objIE.document.all("pbText")
>>> set objQuitFlag = objIE.document.Secret.pubFlag
>>>
>>> objTextLine1.innerTEXT = ""
>>> objTextLine2.innerTEXT = ""
>>>
>>> ' objIE.document.body.innerHTML = "Building Document..." + "<br>load
> wrapped
Quote:
Quote:

>>> time= " + n
>>> objIE.visible = True
>>>
>>> ' set focus to ie
>>> Set objWSHShell = WScript.CreateObject("WScript.Shell")
>>> objWshShell.AppActivate("Microsoft Internet Explorer")
>>>
>>> End Sub
>>>
>>> '---------------------
>>> '
>>> ' Function CloseIE
>>> '
>>> ' Abstract Close the IE Browser Windows
>>> '
>>> ' Parameters
>>> '
>>> ' Return values
>>> '
>>> ' Revision
>>> '
>>> '---------------------
>>>
>>> Private Function CloseIE()
>>>
>>> On Error Resume Next
>>>
>>> objIE.quit
>>> End Function
>>>
>>> '---------------------
>>> '
>>> ' Function SetLine1
>>> '
>>> ' Abstract Set Text Line in the Progress Bar Dialog Box
>>> '
>>> ' Parameters Progress Text
>>> '
>>> ' Return values
>>> '
>>> ' Revision
>>> '
>>> '---------------------
>>>
>>> Private sub SetLine1(sNewText)
>>>
>>> On Error Resume Next
>>>
>>> objTextLine1.innerTEXT = sNewText
>>> End Sub
>>>
>>> '---------------------
>>> '
>>> ' Function SetLine2
>>> '
>>> ' Abstract Set Text Line in the Progress Bar Dialog Box
>>> '
>>> ' Parameters Progress Text
>>> '
>>> ' Return values
>>> '
>>> ' Revision
>>> '
>>> '---------------------
>>>
>>> Private sub SetLine2(sNewText)
>>>
>>> On Error Resume Next
>>>
>>> objTextLine2.innerTEXT = sNewText
>>> End Sub
>>>
>>>
>>> '---------------------
>>> '
>>> ' Function IsQuit
>>> '
>>> ' Abstract Checks if the quit button was pressed
>>> '
>>> ' Parameters Progress Text
>>> '
>>> ' Return values
>>> '
>>> ' Revision
>>> '
>>> '---------------------
>>>
>>> Private function IsQuit()
>>>
>>> On Error Resume Next
>>>
>>> IsQuit=True
>>>
>>> If objQuitFlag.Value<>"quit" Then
>>>
>>> IsQuit=False
>>> End If
>>>
>>> End function
>>>
>>> '---------------------
>>> '
>>> ' Function WriteHtmlToDialog
>>> '
>>> ' Abstract Set HTML Text for the IE Dialog box
>>> '
>>> ' Parameters IE Document Object, Title Text
>>> '
>>> ' Return values
>>> '
>>> ' Revision
>>> '
>>> '---------------------
>>>
>>> Private Sub WriteHtmlToDialog(objDocument, strTitel)
>>>
>>> objDocument.Open
>>>
>>> objDocument.Writeln "<title>" & strTitel & "</title> "
>>>
>>> objDocument.Writeln "<style>"
>>> objDocument.Writeln " BODY {background: Silver} BODY {
> wrapped
Quote:
Quote:

>>> overflow:hidden }"
>>> objDocument.Writeln " P.txtStyle {color: Navy; font-family: Verdana;
>>> "
> wrapped
Quote:
Quote:

>>> _
>>> & " font-size: 10pt; font-weight: bold; margin-left: 10px } "
>>>
>>> objDocument.Writeln " input.pbStyle {color: Navy; font-family:
> wrapped
Quote:
Quote:

>>> Wingdings; " _
>>> & " font-size: 10pt; background: Silver; height: 20px; " _
>>> & " width: 340px } "
>>> objDocument.Writeln "</style>"
>>>
>>> objDocument.Writeln "<div id=""objProgress"" class=""Outer""></div>"
>>>
>>> ' write out text lines...
>>> objDocument.Writeln "<P id=txtMilestone class='txtStyle'
> wrapped
Quote:
Quote:

>>> style='margin-left: 10px'> </P>"
>>> objDocument.Writeln "<P id=txtRemarks class='txtStyle'
> wrapped
Quote:
Quote:

>>> style='margin-left: 10px' ></P>"
>>> objDocument.Writeln "<CENTER>"
>>>
>>> ' write progbar
>>> objDocument.Writeln "<input type='text' id='pbText' class='pbStyle'
> wrapped
Quote:
Quote:

>>> value='' >"
>>> objDocument.Writeln "<br><br>" ' space down a little
>>>
>>> ' write cancel button...
>>> objDocument.Writeln "<input type='button' value='Cancel' " _
>>> & " onclick='SetReturnFlag(""quit"")' >"
>>> objDocument.Writeln "</CENTER>"
>>>
>>> ' write hidden object...
>>> objDocument.Writeln "<form name='secret' >" _
>>> & " <input type='hidden' name='pubFlag' value='run' >" _
>>> & "</form>"
>>>
>>> objDocument.Writeln "<SCRIPT LANGUAGE='VBScript' >"
>>>
>>> ' write "local script" to handle cmdCancel_Click event...
>>> objDocument.Writeln "Sub SetReturnFlag(sFlag)"
>>> objDocument.Writeln " secret.pubFlag.Value = sFlag"
>>> objDocument.Writeln " txtMileStone.style.color = ""Red"" "
>>> objDocument.Writeln " txtRemarks.style.color = ""Red"" "
>>> objDocument.Writeln "End Sub"
>>>
>>> ' progress bar
>>> objDocument.Writeln "Function PctComplete(nPct)"
>>> objDocument.Writeln "pbText.Value = String(nPct,"" "") &
> wrapped
Quote:
Quote:

>>> String(4,""n"")"
>>> objDocument.Writeln "End Function"
>>>
>>> ' calc progress bar and direction
>>> objDocument.Writeln "Sub UpdateProgress()"
>>> objDocument.Writeln "Dim intStep"
>>> objDocument.Writeln "Dim intDirection"
>>>
>>> objDocument.Writeln "If (IsNull(objProgress.getAttribute(""Step"")) =
> wrapped
Quote:
Quote:

>>> True) Then"
>>> objDocument.Writeln "intStep = 0"
>>> objDocument.Writeln "Else"
>>> objDocument.Writeln "intStep = objProgress.Step"
>>> objDocument.Writeln "End If"
>>>
>>> objDocument.Writeln "if
> wrapped
Quote:
Quote:

>>> (IsNull(objProgress.GetAttribute(""Direction""))=True) Then"
>>> objDocument.Writeln "intDirection = 0"
>>> objDocument.Writeln "Else"
>>> objDocument.Writeln "intDirection = objProgress.Direction"
>>> objDocument.Writeln "End If"
>>>
>>> objDocument.Writeln "if intDirection=0 then"
>>> objDocument.Writeln "intStep = intStep + 1"
>>> objDocument.Writeln "else"
>>> objDocument.Writeln "intStep = intStep - 1"
>>> objDocument.Writeln "end if"
>>>
>>> objDocument.Writeln "Call PctComplete(intStep)"
>>>
>>> objDocument.Writeln "if intStep>=23 then"
>>> objDocument.Writeln "intDirection=1"
>>> objDocument.Writeln "end if"
>>> objDocument.Writeln "if intStep<=0 then"
>>> objDocument.Writeln "intDirection=0"
>>> objDocument.Writeln "end if"
>>>
>>> objDocument.Writeln "objProgress.SetAttribute ""Step"", intStep"
>>> objDocument.Writeln "objProgress.SetAttribute ""Direction"",
> wrapped
Quote:
Quote:

>>> intDirection"
>>>
>>> objDocument.Writeln "Window.setTimeout GetRef(""UpdateProgress""), "
>>> &
> wrapped
Quote:
Quote:

>>> conBarSpeed
>>> objDocument.Writeln "End Sub"
>>>
>>> ' timeout function
>>> objDocument.Writeln "Sub DialogHardTimeout()"
>>> objDocument.Writeln "SetReturnFlag(""quit"")"
>>> objDocument.Writeln "End sub"
>>>
>>> objDocument.Writeln "Sub Window_OnLoad()"
>>> objDocument.Writeln "theleft = (screen.availWidth -
> wrapped
Quote:
Quote:

>>> document.body.clientWidth) / 2"
>>> objDocument.Writeln "thetop = (screen.availHeight -
> wrapped
Quote:
Quote:

>>> document.body.clientHeight) / 2"
>>> objDocument.Writeln "window.moveTo theleft,thetop"
>>> objDocument.Writeln "Window.setTimeout GetRef(""UpdateProgress""), "
>>> &
> wrapped
Quote:
Quote:

>>> conBarSpeed
>>> objDocument.Writeln "Window.setTimeout GetRef(""DialogHardTimeout""),
>>> "
> wrapped
Quote:
Quote:

>>> & conForcedTimeOut
>>> objDocument.Writeln "End Sub"
>>>
>>> objDocument.Writeln "</SCRIPT>"
>>>
>>> objDocument.Close
>>>
>>> End Sub
>>>
>>>
>>
>>
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Script Progress VB Script
Sync Center suddenly lost Progress Bar and Sync status Vista General
Progress Status VB Script
Is it possible to allow the use of the status bar via script, using a vbscript? VB Script
Defrag status/progress information Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46