- 目录
- 索引
- 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
SetEnv (Var = Value)
把指定的值赋给变量。
SetEnv, Var, Value Var = Value
参数
备注
默认情况下, 把 Value 赋值给 Var 时忽略其中的前导和尾随空格或 tab. 要避免这种情况, 请使用 AutoTrim Off 中描述的方法.
“SetEnv”名称容易让人误解,是来自 AutoIt v2 的遗留物。与 AutoIt v2 不同, AutoHotkey 没有把它的变量保存在系统环境中. 这是由于性能会变差且操作系统限制环境变量大小在 32 KB 之内. 使用 EnvSet 而不是 SetEnv 来设置 环境变量.
通过赋值为空可以释放大变量占用的内存,例如 Var =
。
这个命令以及其他任何接受 OutputVar 参数的命令都可以创建伪数组。这可以通过让 OuputVar 包含到另一个变量的引用来实现,例如 array%i% = 123
。请参阅数组了解更多细节。
相关
AutoTrim, EnvSet, EnvAdd, EnvSub, EnvMult, EnvDiv, If, 数组
示例
Var1 = This is a string. Color2 = 450 Color3 = %Var1% Array%i% = %A_TICKCOUNT%