独自のカウントダウンが本当に必要な場合は、MsgBox として機能する GUI を作成できます。

この例では、4 つのパラメーターがあります。
- ウィンドウのタイトル
- メッセージ
- 秒数
- ラベルが消えるときに呼び出すラベルの名前。
コードが通常の MsgBox から次のように変更される方法を次に示します。
MsgBox, Title, Msg
OtherCode
return
に
MsgBoxTimed("Title", "Msg", 10, "Foo")
return
Foo:
OtherCode
return
この関数は同じファイルにある必要があります。#Include
MsgBoxTimed(title, msg, seconds, complete="") {
static init = false, _seconds, _complete
global Msg92, Seconds92
if (!init)
{
init := true
Gui, 92:Font, s24
Gui, 92:Add, Text, vMsg92 Center w360, %msg%
Gui, 92:Font, s30 cRed
Gui, 92:Add, Text, vSeconds92 Center w360, %seconds%
}
_seconds := seconds
_complete := complete
GuiControl, 92:, Msg92, %msg%
Gui, 92:Show, w400 h150, %title%
Update92:
GuiControl, 92:, Seconds92, %_seconds%
_seconds -= 1
if (_seconds > 0) {
SetTimer, Update92, -1000
}
else {
Gui, 92:Hide
if (_complete)
SetTimer, %_complete%, -1
}
return
}