LoginSignup
0
1

More than 3 years have passed since last update.

ポップアップに対して指定した秒数操作が無かったらBotの実行を止める方法 with VBS

Last updated at Posted at 2019-10-19

背景

ユーザーがPCの画面を見ているときだけ実行したい。みたいなケースがあり、作ってみました。
OKとキャンセルのボタンがあるポップアップが出て、指定した秒数の間操作がないと自動的に閉じて、Bot自身の実行も止めてくれる。というものです。

試した環境

Windows 10
Automation Anywhere Enterprise v11.3.2
Notepad++

作りかた

Automation Anywhereの標準のPromptコマンドでは希望の動作が実現できないので、VBScriptを使います。
以下のようなコードを書いてAutomation AnywhereフォルダのMy Scriptsに保存。

PromptForYesNoWithTimeout.vbs
Dim vResult
WScript.Timeout = 30 'タイムアウトするまでの時間(秒)

vResult = MsgBox ("このBotを実行しますか?", 65, "Automation Anywhere Enterprise")
Wscript.Stdout.Writeline(vResult)

以下のようなBotを作る。
image.png

Run Scriptコマンドの中身はこんな感じ。
image.png

ユーザーの操作によって、変数\$Prompt-Assignment$に入る値が変わります。
OKを押したら1
Cancelを押したら2
操作が無くタイムアウトしたら空の値

動かしてみる

Botをw実行すると・・・
image.png

といったポップアップが出て、指定した秒数の間待機したあと、操作が無ければBotの実行が停止されます。
Cancelを押した場合も同様にBotの実行は停止されます。

0
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
0
1