ErrorLevel

명령어의 성공 여부를 알리기 위해 설정되는 내장 변수 입니다 (모든 명령어가 ErrorLevel의 값을 변경하는 것은 아닙니다). 값이 0이면 보통 성공을 나타내고, 다른 값은 보통 실패를 나타냅니다. ErrorLevel의 값을 직접 설정해도 됩니다.

RunWait가 자신이 실행한 프로그램의 종료 코드가 되도록 ErrorLevel를 설정하는 것은 특별히 흥미롭습니다. 대부분의 프로그램은 성공적으로 완료하면 종료 코드를 0으로 산출합니다.

쓰레드마다 자신의 ErrorLevel을 보유합니다. 현재 쓰레드가 다른 쓰레드에 의해 인터럽트 되더라도, 원래 쓰레드가 재개하면, 여전히 자신의 원래 ErrorLevel을 보유합니다. 인터럽트 한 쓰레드가 설정한 ErrorLevel이 아니라는 뜻입니다.

주의: 어떤 명령어는 ErrorLevel에 1보다 큰 값을 설정하므로, ErrorLevel이 1인가를 점검하지 말고, 대신에 ErrorLevel이 0이 아닌가를 점검하는 것이 좋습니다.

The following list contains all commands, functions and GUI/Control events which set ErrorLevel, including the possible ErrorLevel values:

Language element ErrorLevel values
ClipWait0, 1
Control0, 1
ControlClick0, 1
ControlFocus0, 1
ControlGet0, 1
ControlGetFocus0, 1
ControlGetText0, 1
ControlMove0, 1
ControlSend / ControlSendRaw0, 1
ControlSetText0, 1
DllCall()0, -1, -2, -3, -4, n, An
Drive0, 1
DriveGet0, 1
EnvSet0, 1
EnvUpdate0, 1
FileAppend0, 1
FileCopy0, n
FileCopyDir0, 1
FileCreateDir0, 1
FileCreateShortcut0, 1
FileDelete0, n
FileGetAttrib0, 1
FileGetShortcut0, 1
FileGetSize0, 1
FileGetTime0, 1
FileGetVersion0, 1
FileInstall0, 1
FileMove0, n
FileMoveDir0, 1
FileRead0, 1
FileReadLine0, 1
FileRecycle0, 1
FileRecycleEmpty0, 1
FileRemoveDir0, 1
FileSelectFile0, 1
FileSelectFolder0, 1
FileSetAttrib0, n
FileSetTime0, 1
GroupActivate0, 1
Gui: GuiSize event0, 1, 2
Gui: GuiDropFiles event0, n
GuiControl0, 1
GuiControlGet0, 1
Gui control: Link click event문자열
Gui control: Custom event0, n
Gui control: ListView item change eventsubset of "SsFfCc"
Hotkey0, 1, 2, 3, 4, 5, 6, 98, 99
ImageSearch0, 1, 2
IniDelete0, 1
IniWrite0, 1
Input0, 1, NewInput, Max, Timeout, Match, EndKey:Name
InputBox0, 1, 2
KeyWait0, 1
Menu0, 1
PixelGetColor0, 1
PixelSearch0, 1, 2
PostMessage0, 1
Process0, PID
RegDelete0, 1
RegExMatch()0, 문자열, -n
RegExReplace()0, 문자열, -n
RegRead0, 1
RegWrite0, 1
Run0, ERROR
RunWaitn, ERROR
SendMessageFAIL, n
SetWorkingDir0, 1
Sort: U option0, n
SoundGet0, 문자열
SoundGetWaveVolume0, 1
SoundPlay0, 1
SoundSet0, 문자열
SoundSetWaveVolume0, 1
StatusBarGetText0, 1
StatusBarWait0, 1, 2
StringGetPos0, 1
StringReplace0, 1, n
UrlDownloadToFile0, 1
WinGetText0, 1
WinMenuSelectItem0, 1
WinSet Style/ExStyle/Region0, 1
WinWait0, 1
WinWaitActive / WinWaitNotActive0, 1
WinWaitClose0, 1

예제

Waits a maximum of 1 second until MyWindow exists. If WinWait times out, ErrorLevel is set to 1, otherwise to 0.

WinWait, MyWindow,, 1
if ErrorLevel   ; 즉, 비어 있지 않거나 0이면.
    MsgBox, 창이 존재하지 않습니다.
else
    MsgBox, 창이 존재합니다.