0
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 1 year has passed since last update.

VBScriptでどうしてもプログレスバーを使いたい

Posted at

作業の進捗状況を表示するプログレスバーです。
サンプルでは、5% = 1マスずつ増えていきます。

Option Explicit

' オブジェクトの生成
Dim objWsh : Set objWsh = Wscript.CreateObject("Wscript.shell")

' 当スクリプトの名前を取得
Dim strScriptName   : strScriptName = WScript.ScriptName

' 当スクリプトの引数が空でも動作するようにON ERROR RESUME NEXTを使う
ON ERROR RESUME NEXT

Dim strArg1 : strArg1 = Wscript.Arguments(0)
' 引数が"ESC"であればESCを叩きつける
If strArg1 = "ESC" Then
    WScript.Sleep 100
    objWsh.SendKeys "{" & strArg1 & "}"
    Wscript.Quit
End If

ON ERROR GOTO 0

' 引数がなければ以下に進む

Dim i
For i = 1 To 20
    ' 当スクリプトを"ESC"を引数にして実行し直す
    objWsh.Run (Wscript.ScriptFullName & " ESC")

    ' 次に進捗状況を表すメッセージを表示する
    Wscript.Echo "進捗状況 " & i*5 & "%" & vbCr & String(i, "■") & String(20-i, "□")

    ' ESCが叩きつけられるので進捗状況が次々進む(ように見える)
Next
0
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
0
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?