On Jul 24, 12:01*pm, "Pascal Boivin" <pascal.boi...@xxxxxx>
wrote:
> Hi
>
> Is it possible to show a window from a VBScript? *I would like to show
> some status while the script is working. *The script is run from WSH on
> the command line.
>
> Thanks
>
> Sub BigProcess
> Dim I
> * <Show a progess window> "Starting..."
> * For I = 1 To 100
> * * Call DoSomething(I)
> * * <Update the progress window> "Done: " & FormatNumber(I) & "%"
> * Next
> * <Close the progress window>
> End Sub Here's an example I had handy ...
Dim oIE, oPgCtl, i
Set oIE = CreateObject("InternetExplorer.Application")
oPgCtl = ProgressBar(oIE) ' Create control and return object array
' properties can be altered before revealing bar
' For example, ...
oPgCtl(0).max = 250
oIE.Visible = 1 ' Reveals the progress bar
' For example, write an initial message to Message Area
oPgCtl(1).innerHTML = "<font size=+1><b>Running ...</b></font>"
' Simulate a proccess delay & update progress bar
With oPgCtl(0) ' Progress bar
For i=.min to .max step 10 ' step changes progress bar increment
.value = CSng(i)
Wscript.sleep 100 ' process goes here
Next
End With
' For example, write closing message to Message Area
oPgCtl(1).innerHTML = "<font size=+1><b>Maximum reached: " _
& oPgCtl(0).value & "</b></font>"
wsh.sleep 2000 ' wait 2 seconds - just for demo
oIE.quit
' -------------------------------------------------------------------
' Requires "InternetExplorer.Application" object (oIE) input
' Returns two element array:
'
' element 0 is the Progress Bar control object - 5 properties
' .focus, .value, .min, .max, .appearance & .borderstyle
'
' element 1 is a message area to receive progress text (HTML)
'
Function ProgressBar(oIE)
Dim oPgCtl, h, w
With oIE
.RegisterAsDropTarget = False
.Resizable = 0 : addressbar = 0 : menubar = 0 : .toolbar = 0
.statusbar = 0
'.FullScreen = True ' removes "chrome", but don't use with IE7+
.Navigate "about
:blank"
Do Until .ReadyState = 4 : WScript.Sleep 50 : Loop
.document.open
.document.write _
"<html><head><title>Progress</title></head>" _
& "<body bgcolor=silver scroll=no" _
& " style='border-Style

utset;border-Width:3px'><center>" _
& "<table bgcolor=lightskyblue width=100% height=100%>" _
& "<tr valign=middle><td align=center>Progress: <object "_
& "classid=""clsid:35053A22-8589-11D1-B16A-00C0F0283628"" " _
& "id=PrgBar height=20 width=500></object>" _
& "</td></tr><tr><td align=center id=amsg> " _
& "</td></tr></table></center></body></html>"
.document.close
.document.parentWindow.status = "Working"
Do Until .ReadyState = 4 : WScript.Sleep 50 : Loop
with .document.parentwindow.screen
h = .availheight
w = .availwidth
end with
.height = h\8 : .width = 3 * (w\4)
.top = h\10 : .left = w\10
Set oPgCtl = .document.applets("PrgBar")
End with
' Bring progress bar to the front
CreateObject("Wscript.Shell").Appactivate "Progress"
With oPgCtl ' defaults - can be changed
.focus
.min = 0
.max = 100
.appearance = 1 'OR 0
.borderstyle = 0 'OR 1
End With
' Return references to the Progress Bar Control and the Message Area
Progressbar = Array(oPgCtl, oIE.document.all.amsg)
End Function
' -------------------------------------------------------------------