- 目录
- 索引
- AutoHotkey
- 指南(快速入门)
- FAQ(常见问题)
- 命令和函数索引
- 脚本展示
- 更新历史
- ►基本用法和语法
- 热键
- 热字串和自动替换
- 重映射按键和鼠标按钮
- 按键列表(键盘、鼠标和操纵杆)
- 脚本
- 变量和表达式
- 函数
- 调试(DBGp)客户端
- ►对象
- 基本用法
- 扩展用法
- 自定义对象
- 默认基对象
- 实现
- 对象
- 枚举器对象
- File 对象
- Func 对象
- ►迁移到 AutoHotkey 1.1(AutoHotkey_L)
- AutoHotkey_L 新特性
- 脚本兼容性
- ►环境管理
- ClipWait
- EnvGet
- EnvSet
- EnvUpdate
- ►本机代码互操作
- DllCall
- NumGet
- NumPut
- RegisterCallback
- StrPut()/StrGet()
- ►COM
- ComObjActive
- ComObjArray
- ComObjConnect
- ComObjCreate
- ComObjGet
- ComObjError
- ComObjFlags
- ComObjQuery
- ComObjType
- ComObjValue
- ObjAddRef / ObjRelease
- ►文件、目录和磁盘管理
- Drive
- DriveGet
- DriveSpaceFree
- FileAppend
- FileCopy
- FileCopyDir
- FileCreateDir
- FileCreateShortcut
- FileDelete
- FileEncoding
- FileGetAttrib
- FileGetShortcut
- FileGetSize
- FileGetTime
- FileGetVersion
- FileInstall
- FileMove
- FileMoveDir
- FileOpen()
- FileReadLine
- FileRead
- FileRecycle
- FileRecycleEmpty
- FileRemoveDir
- FileSelectFile
- FileSelectFolder
- FileSetAttrib
- FileSetTime
- IfExist/IfNotExist
- IniDelete
- IniRead
- IniWrite
- Loop(文件和文件夹)
- Loop(读取文件内容)
- SetWorkingDir
- SplitPath
- ►流程控制
- #Include/#IncludeAgain
- { ... }(区块)
- Break
- Catch
- Continue
- Critical
- Else
- Exit
- ExitApp
- Finally
- For 循环
- Gosub
- Goto
- ►If 命令
- If(传统型)
- If(表达式)
- If var [not] between Low and High
- If var is [not] type
- If var [not] in/contains MatchList
- IfExist/IfNotExist
- IfInString/IfNotInString
- IfMsgBox
- IfWinActive/IfWinNotActive
- IfWinExist/IfWinNotExist
- ►Loop 命令
- Loop
- Loop(文件和文件夹)
- Loop(解析字符串)
- Loop(读取文件内容)
- Loop(注册表)
- OnExit
- Pause
- Reload
- Return
- SetBatchLines
- SetTimer
- Sleep
- Suspend
- Thread
- Throw
- Try
- Until
- While 循环
- ►内置函数
- Asc
- Chr
- FileExist
- GetKeyName/VK/SC
- GetKeyState
- InStr
- IsByRef
- IsFunc
- IsLabel
- NumGet
- NumPut
- OnMessage
- RegExMatch
- RegExReplace
- RegisterCallback
- StrLen
- StrPut()/StrGet()
- StrSplit
- SubStr
- VarSetCapacity
- WinActive
- WinExist
- ►GUI、MsgBox、InputBox 及其他对话框
- FileSelectFile
- FileSelectFolder
- Gui
- Gui 控件类型
- GuiControl
- GuiControlGet
- Gui ListView 控件
- Gui TreeView 控件
- IfMsgBox
- InputBox
- Menu
- MsgBox
- OnMessage
- Progress
- SplashImage
- SplashTextOn/SplashTextOff
- ToolTip
- TrayTip
- ►鼠标和键盘
- ►热键和热字串
- #HotkeyInterval
- #HotkeyModifierTimeout
- #Hotstring
- #If
- #IfTimeOut
- #IfWinActive/Exist
- #InputLevel
- #MaxHotkeysPerInterval
- #MaxThreads
- #MaxThreadsBuffer
- #MaxThreadsPerHotkey
- #MenuMaskKey
- #UseHook
- Hotkey
- ListHotkeys
- Suspend
- #InstallKeybdHook
- #InstallMouseHook
- #KeyHistory
- BlockInput
- Click
- ControlClick
- ControlSend/ControlSendRaw
- CoordMode
- GetKeyState
- 按键列表(键盘、鼠标和操纵杆)
- KeyHistory
- KeyWait
- Input
- MouseClick
- MouseClickDrag
- MouseGetPos
- MouseMove
- Send/SendRaw/SendInput/SendPlay/SendEvent
- SendLevel
- SendMode
- SetDefaultMouseSpeed
- SetKeyDelay
- SetMouseDelay
- SetNumScrollCapsLockState
- SetStoreCapslockMode
- ►数学相关
- Abs
- Ceil
- Exp
- Floor
- Log
- Ln
- Mod
- Random
- Round
- SetFormat
- Sqrt
- Sin/Cos/Tan
- ASin/ACos/ATan
- Transform
- ►屏幕管理
- ImageSearch
- PixelGetColor
- PixelSearch
- ►杂项命令
- #NoTrayIcon
- #SingleInstance
- #Warn
- AutoTrim
- Edit
- ListLines
- ListVars
- OutputDebug
- SysGet
- Transform
- URLDownloadToFile
- VarSetCapacity
- ►进程管理
- Process
- Run/RunWait
- RunAs
- Shutdown
- ►注册表管理
- Loop(注册表)
- RegDelete
- RegRead
- RegWrite
- SetRegView
- ►声音命令
- SoundBeep
- SoundGet
- SoundGetWaveVolume
- SoundPlay
- SoundSet
- SoundSetWaveVolume
- ►字符串管理
- FormatTime
- IfInString/IfNotInString
- If var [not] in/contains MatchList
- InStr()
- Loop(解析字符串)
- RegExMatch()
- RegExReplace()
- SetEnv (var = value)
- SetFormat
- Sort
- StringCaseSense
- StringGetPos
- StringLeft/StringRight
- StringLen
- StringLower/StringUpper
- StringMid
- StringReplace
- StringSplit
- StringTrimLeft/StringTrimRight
- StrLen()
- StrPut()/StrGet()
- StrSplit()
- SubStr()
- Trim()
- ►窗口管理
- ►控件
- Control
- ControlClick
- ControlFocus
- ControlGet
- ControlGetFocus
- ControlGetPos
- ControlGetText
- ControlMove
- ControlSend/ControlSendRaw
- ControlSetText
- Menu
- PostMessage/SendMessage
- SetControlDelay
- WinMenuSelectItem
- ►窗口组
- GroupActivate
- GroupAdd
- GroupClose
- GroupDeactivate
- #WinActivateForce
- DetectHiddenText
- DetectHiddenWindows
- IfWinActive/IfWinNotActive
- IfWinExist/IfWinNotExist
- SetTitleMatchMode
- SetWinDelay
- StatusBarGetText
- StatusBarWait
- WinActivate
- WinActivateBottom
- WinClose
- WinGet
- WinGetActiveStats
- WinGetActiveTitle
- WinGetClass
- WinGetPos
- WinGetText
- WinGetTitle
- WinHide
- WinKill
- WinMaximize
- WinMinimize
- WinMinimizeAll/WinMinimizeAllUndo
- WinMove
- WinRestore
- WinSet
- WinSetTitle
- WinShow
- WinWait
- WinWaitActive/WinWaitNotActive
- WinWaitClose
- ►#指令
- #AllowSameLineComments
- #ClipboardTimeout
- #CommentFlag
- #ErrorStdOut
- #EscapeChar
- #HotkeyInterval
- #HotkeyModifierTimeout
- #Hotstring
- #If
- #IfWinActive/Exist
- #IfTimeout
- #Include/#IncludeAgain
- #InputLevel
- #InstallKeybdHook
- #InstallMouseHook
- #KeyHistory
- #MaxHotkeysPerInterval
- #MaxMem
- #MaxThreads
- #MaxThreadsBuffer
- #MaxThreadsPerHotkey
- #MenuMaskKey
- #NoEnv
- #NoTrayIcon
- #Persistent
- #SingleInstance
- #UseHook
- #Warn
- #WinActivateForce
ErrorLevel
这是表示一些命令执行成功与否的内置变量(有些命令不会改变 ErrorLevel 的值)。值为 0 时通常表示成功, 而其他值一般表示失败. 您也可以自己设置 ErrorLevel 的值.
特别有意义的是 RunWait 会把 ErrorLevel 设置为它所运行程序的退出代码. 大多数程序在成功完成时会产生退出代码零.
每个 线程 会保持它自己的 ErrorLevel 的值, 这意味着如果 当前线程 被其他线程中断, 那么当原始线程恢复时它仍会拥有它原来的 ErrorLevel 值, 而不是由中断线程设置的 ErrorLevel 值.
注意: 由于一些命令会设置大于 1 的 ErrorLevel 值, 所以最好不要检查 ErrorLevel 是否大于 1, 而是检查它是否等于零.
示例
WinWait, MyWindow, , 1 if ErrorLevel ; 即既不是空值, 也不是零. MsgBox, The window does not exist. else MsgBox, The window exists.