1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【VBS】プログレス表示

Posted at
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

参考
https://neos21.hatenablog.com/entry/2016/06/24/000000

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?