progress.vbs
Dim ie
' IE の初期化
Function initializeIe()
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Navigate("about:blank")
.ToolBar = False
.StatusBar = False
' 幅・高さの設定
.Width = 300
.Height = 200
' 画面右上に配置する。"parentWindow.screen" はパスカルケースで書くと認識されない
.Top = 0
.Left = .Document.parentWindow.screen.Width - 300
.Document.Charset = "UTF-8"
.Visible = True
.Document.Title = "スクリプト実行中"
End With
End Function
' メッセージを IE に追記する
'
' 引数のメッセージを IE の最終行に追記する。
' 最終行が表示されるようにスクロール位置を最下部に設定する。
Function updateMsg(value)
With ie
.Document.Body.innerHTML = .Document.Body.innerHTML & value & "<br>"
.Document.Script.setTimeout "javascript:scrollTo(0," & .Document.Body.ScrollHeight & ");", 0
End With
End Function
' IE を終了する
Function closeIe()
ie.Quit
Set ie = Nothing
End Function
main.vbs
Set objFso = Wscript.CreateObject("Scripting.FileSystemObject")
Execute objFso.OpenTextFile("progress.vbs", 1).ReadAll()
' IE の宣言と初期化
initializeIe()
s = "aaa"
updateMsg "処理を開始します..."
' 処理…
For i = 0 To 10
updateMsg s
Next
' 完了
updateMsg "スクリプト処理完了!"
MsgBox "スクリプト処理が完了しました。"
' IE を終了させスクリプトを閉じる
closeIe()
WScript.Quit