If系のコマンドで条件に一致しなかったときの動作を指定
Else
Ifコマンドと条件に一致したときに実行させたいコマンド(もしくはブロック)に続いてelseを使用すると、条件に一致しなかったときに実行させたい動作を記述できる。
elseのあとにはスペースで区切って(カンマではない)実行させたいコマンドを記述することができる。
「{」は「else{」のようにスペースを空けずに記述してよい。
「else if...」というようにして、AでなくBなら……というような分岐を記述することも出来る。
See Blocks. Also, every IF-command can use ELSE, including IfWinActive, IfWinExist, IfMsgBox, IfInString, IfBetween, IfIn, IF, and IF (expression)
IfWinExist, Untitled - Notepad
{
WinActivate
Sleep, 1
}
else
{
WinActivate, Some Other Window
Sleep, 1
}
if x = 1
Gosub, a1
else if x = 2 ; "else if" style
Gosub, a2
else IfEqual, x, 3 ; alternate style
{
Gosub, a3
Sleep, 1
}
else Gosub, a4 ; i.e. Any single command can be on the same line with an ELSE.
;Also OK:
IfEqual, y, 1, Gosub, b1
else {
Sleep, 1
Gosub, b2
}