LoginSignup
1
1

More than 1 year has passed since last update.

VBScriptで、すぐに消えるダイアログを表示する

Posted at

例えば BizRobo! は、Automation Anywhere や UiPath のようにダイアログを表示しません。
多分設計思想的にダイアログを出さないのだと思いますが、処理の途中に出した方が便利な時もあります。
以下のようなVBSで、n秒で消えるダイアログを表示できます。

呼び出す時の引数は、以下の3つです。

  • args(0) = prompt(本文)
  • args(1) = title(タイトル)
  • args(2) = waittime(待機秒、消さない時は0)
ShowPopup.vbs
Option Explicit

On Error Resume Next

'prompt 本文
'title タイトル
'waittime 待機秒(消さない時は0)

Dim arg

'引数の数は3
If WScript.Arguments.Count <> 3 Then
    WScript.Quit(-1)
End If

Set arg = WScript.Arguments

Dim prompt
Dim title
Dim waittime

prompt = arg(0)
title = arg(1)
waittime = arg(2)

'メッセージは1文字以上
If Len(prompt) =0 Then
    WScript.Quit(-2)
End If

'タイトルは1文字以上
If Len(title) =0 Then
    WScript.Quit(-2)
End If

'第3引数は数字
If IsNumeric(waittime) =0 Then
    WScript.Quit(-3)
End If

Dim WSH
Set WSH = CreateObject("WScript.Shell")
WSH.Popup prompt, waittime, title, vbExclamation
Set WSH = Nothing

'0以外はエラー
WScript.Quit(Err.Number)

他のvbsから呼び出すならこんな感じ。

呼び出し方法
Set obj = WScript.CreateObject("WScript.Shell")
ret = obj.Run("ShowPopup.vbs 本文 タイトル 3",0,True)
1
1
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
1