├── .gitignore ├── docs ├── static │ ├── ahk16.png │ ├── ahk_logo.png │ ├── ctrl_ddl.png │ ├── ctrl_tab.png │ ├── dlg_file.png │ ├── ahkfile16.png │ ├── ctrl_button.png │ ├── ctrl_check.png │ ├── ctrl_combo.png │ ├── ctrl_edit.png │ ├── ctrl_group.png │ ├── ctrl_hotkey.png │ ├── ctrl_link.png │ ├── ctrl_list.png │ ├── ctrl_menu.png │ ├── ctrl_radio.png │ ├── ctrl_slider.png │ ├── ctrl_status.png │ ├── ctrl_text.png │ ├── ctrl_updown.png │ ├── dlg_folder.png │ ├── dlg_input.png │ ├── dlg_message.png │ ├── dlg_tooltip.png │ ├── dlg_traytip.png │ ├── fonts │ │ ├── icons.eot │ │ ├── icons.ttf │ │ └── icons.woff │ ├── ctrl_datetime.png │ ├── ctrl_listview.png │ ├── ctrl_monthcal.png │ ├── ctrl_progress.png │ ├── ctrl_treeview.png │ ├── ahk_logo_no_text.png │ └── source │ │ ├── check_data.ahk │ │ ├── data_translate.js │ │ └── data_deprecate.js ├── scripts │ ├── MouseGestures.zip │ ├── WinLIRC.htm │ ├── Numpad000.htm │ ├── IntelliSense.htm │ ├── JoystickTest.htm │ ├── MouseGestures.htm │ ├── VolumeOSD.htm │ ├── WindowShading.htm │ ├── EasyWindowDrag.htm │ ├── JoystickMouse.htm │ ├── KeyboardOnScreen.htm │ ├── TooltipMouseMenu.htm │ ├── FavoriteFolders.htm │ ├── NumpadMouse.htm │ ├── MinimizeToTrayMenu.htm │ ├── MsgBoxButtonNames.htm │ ├── EasyWindowDrag_(KDE).htm │ ├── ContextSensitiveHelp.htm │ ├── Seek_(SearchTheStartMenu).htm │ ├── MsgBoxButtonNames.ahk │ ├── EasyWindowDrag.ahk │ ├── WindowShading.ahk │ ├── Numpad000.ahk │ └── ContextSensitiveHelp.ahk ├── misc │ ├── remove-userchoice.reg │ ├── Macros.htm │ ├── Override.htm │ └── Winamp.htm ├── index.html ├── commands │ ├── ObjBindMethod.htm │ ├── WinMinimizeAll.htm │ ├── MenuGetName.htm │ ├── IsObject.htm │ ├── WinGetActiveTitle.htm │ ├── _AllowSameLineComments.htm │ ├── FileRecycleEmpty.htm │ ├── DriveSpaceFree.htm │ ├── EnvUpdate.htm │ ├── IsByRef.htm │ ├── Asc.htm │ ├── _WinActivateForce.htm │ ├── Trim.htm │ ├── FileCreateDir.htm │ ├── StrLen.htm │ ├── _HotkeyInterval.htm │ ├── ComObjValue.htm │ ├── OutputDebug.htm │ ├── Ord.htm │ ├── Func.htm │ ├── Goto.htm │ ├── SoundBeep.htm │ ├── _CommentFlag.htm │ ├── _NoTrayIcon.htm │ ├── IfMsgBox.htm │ ├── IniDelete.htm │ ├── MenuGetHandle.htm │ ├── IfExist.htm │ ├── Chr.htm │ ├── ExitApp.htm │ ├── _KeyHistory.htm │ ├── GetKey.htm │ ├── StringLen.htm │ ├── WinGetClass.htm │ ├── IsFunc.htm │ ├── _MaxHotkeysPerInterval.htm │ ├── IsLabel.htm │ ├── Until.htm │ ├── FileDelete.htm │ ├── WinShow.htm │ ├── _EscapeChar.htm │ ├── FileRecycle.htm │ ├── _NoEnv.htm │ ├── EnvGet.htm │ ├── WinRestore.htm │ ├── EnvMult.htm │ ├── Break.htm │ ├── WinGetTitle.htm │ ├── FileRemoveDir.htm │ ├── EnvSet.htm │ ├── ComObjCreate.htm │ ├── ObjAddRef.htm │ ├── WinHide.htm │ ├── ComObjGet.htm │ ├── WinGetActiveStats.htm │ ├── FileEncoding.htm │ ├── _MaxMem.htm │ ├── _InstallMouseHook.htm │ ├── FileGetVersion.htm │ ├── _InputLevel.htm │ ├── EnvDiv.htm │ ├── DetectHiddenText.htm │ ├── _IfTimeout.htm │ ├── _ClipboardTimeout.htm │ ├── ListHotkeys.htm │ ├── WinMaximize.htm │ ├── SoundGetWaveVolume.htm │ ├── Shutdown.htm │ ├── WinSetTitle.htm │ └── Exit.htm ├── Welcome.htm ├── objects │ └── Enumerator.htm └── search.htm ├── index.html └── Project.hhp /.gitignore: -------------------------------------------------------------------------------- 1 | *.chm 2 | # Ignore auto-generated files 3 | Index.hhk 4 | Table of Contents.hhc 5 | -------------------------------------------------------------------------------- /docs/static/ahk16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ahk16.png -------------------------------------------------------------------------------- /docs/static/ahk_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ahk_logo.png -------------------------------------------------------------------------------- /docs/static/ctrl_ddl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_ddl.png -------------------------------------------------------------------------------- /docs/static/ctrl_tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_tab.png -------------------------------------------------------------------------------- /docs/static/dlg_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/dlg_file.png -------------------------------------------------------------------------------- /docs/static/ahkfile16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ahkfile16.png -------------------------------------------------------------------------------- /docs/static/ctrl_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_button.png -------------------------------------------------------------------------------- /docs/static/ctrl_check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_check.png -------------------------------------------------------------------------------- /docs/static/ctrl_combo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_combo.png -------------------------------------------------------------------------------- /docs/static/ctrl_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_edit.png -------------------------------------------------------------------------------- /docs/static/ctrl_group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_group.png -------------------------------------------------------------------------------- /docs/static/ctrl_hotkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_hotkey.png -------------------------------------------------------------------------------- /docs/static/ctrl_link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_link.png -------------------------------------------------------------------------------- /docs/static/ctrl_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_list.png -------------------------------------------------------------------------------- /docs/static/ctrl_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_menu.png -------------------------------------------------------------------------------- /docs/static/ctrl_radio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_radio.png -------------------------------------------------------------------------------- /docs/static/ctrl_slider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_slider.png -------------------------------------------------------------------------------- /docs/static/ctrl_status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_status.png -------------------------------------------------------------------------------- /docs/static/ctrl_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_text.png -------------------------------------------------------------------------------- /docs/static/ctrl_updown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_updown.png -------------------------------------------------------------------------------- /docs/static/dlg_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/dlg_folder.png -------------------------------------------------------------------------------- /docs/static/dlg_input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/dlg_input.png -------------------------------------------------------------------------------- /docs/static/dlg_message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/dlg_message.png -------------------------------------------------------------------------------- /docs/static/dlg_tooltip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/dlg_tooltip.png -------------------------------------------------------------------------------- /docs/static/dlg_traytip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/dlg_traytip.png -------------------------------------------------------------------------------- /docs/static/fonts/icons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/fonts/icons.eot -------------------------------------------------------------------------------- /docs/static/fonts/icons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/fonts/icons.ttf -------------------------------------------------------------------------------- /docs/static/ctrl_datetime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_datetime.png -------------------------------------------------------------------------------- /docs/static/ctrl_listview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_listview.png -------------------------------------------------------------------------------- /docs/static/ctrl_monthcal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_monthcal.png -------------------------------------------------------------------------------- /docs/static/ctrl_progress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_progress.png -------------------------------------------------------------------------------- /docs/static/ctrl_treeview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ctrl_treeview.png -------------------------------------------------------------------------------- /docs/static/fonts/icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/fonts/icons.woff -------------------------------------------------------------------------------- /docs/scripts/MouseGestures.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/scripts/MouseGestures.zip -------------------------------------------------------------------------------- /docs/static/ahk_logo_no_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstacruz/AutoHotkey_L-Docs/master/docs/static/ahk_logo_no_text.png -------------------------------------------------------------------------------- /docs/misc/remove-userchoice.reg: -------------------------------------------------------------------------------- 1 | Windows Registry Editor Version 5.00 2 | 3 | [-HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ahk\UserChoice] 4 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 |Redirecting to docs/AutoHotkey.htm.
9 | 10 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |Redirecting to AutoHotkey.htm.
11 | 12 | -------------------------------------------------------------------------------- /docs/scripts/WinLIRC.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to WinLIRC Client.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/Numpad000.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Numpad 000 Key.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/IntelliSense.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to IntelliSense.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/JoystickTest.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Joystick Test Script.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/MouseGestures.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Mouse Gestures.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/VolumeOSD.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Volume On-Screen-Display (OSD).
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/WindowShading.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Window Shading.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/EasyWindowDrag.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Easy Window Dragging.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/JoystickMouse.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Using a Joystick as a Mouse.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/KeyboardOnScreen.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to On-Screen Keyboard.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/TooltipMouseMenu.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to ToolTip Mouse Menu.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/FavoriteFolders.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Easy Access to Favorite Folders.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/NumpadMouse.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Using Keyboard Numpad as a Mouse.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/MinimizeToTrayMenu.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Minimize Window to Tray Menu.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/MsgBoxButtonNames.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Changing MsgBox's Button Names.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/EasyWindowDrag_(KDE).htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Easy Window Dragging (KDE style).
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/ContextSensitiveHelp.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Context Sensitive Help in Any Editor.
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/Seek_(SearchTheStartMenu).htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |Redirecting to Seek (Search the Start Menu).
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/MsgBoxButtonNames.ahk: -------------------------------------------------------------------------------- 1 | ; Changing MsgBox's Button Names 2 | ; https://www.autohotkey.com 3 | ; This is a working example script that uses a timer to change 4 | ; the names of the buttons in a message box. Although the button 5 | ; names are changed, the IfMsgBox command still requires that the 6 | ; buttons be referred to by their original names. 7 | 8 | #SingleInstance 9 | SetTimer, ChangeButtonNames, 50 10 | MsgBox, 4, Add or Delete, Choose a button: 11 | IfMsgBox, YES 12 | MsgBox, You chose Add. 13 | else 14 | MsgBox, You chose Delete. 15 | return 16 | 17 | ChangeButtonNames: 18 | IfWinNotExist, Add or Delete 19 | return ; Keep waiting. 20 | SetTimer, ChangeButtonNames, Off 21 | WinActivate 22 | ControlSetText, Button1, &Add 23 | ControlSetText, Button2, &Delete 24 | return 25 | -------------------------------------------------------------------------------- /Project.hhp: -------------------------------------------------------------------------------- 1 | [OPTIONS] 2 | Binary Index=No 3 | Compatibility=1.1 or later 4 | Compiled file=AutoHotkey.chm 5 | Default Window=Contents 6 | Default topic=docs\AutoHotkey.htm 7 | Display compile progress=No 8 | Full-text search=Yes 9 | Index file=Index.hhk 10 | Language=0x409 English (United States) 11 | Title=AutoHotkey Help 12 | 13 | [WINDOWS] 14 | Contents="AutoHotkey Help",,,"docs\AutoHotkey.htm","docs\AutoHotkey.htm",,,,,0x73500,,0x10200e,[200,0,1080,700],,,,,3,,0 15 | 16 | 17 | [FILES] 18 | docs\search.htm 19 | docs\settings.htm 20 | docs\static\content.css 21 | docs\static\dark.css 22 | docs\static\ahk_logo.png 23 | docs\static\fonts\icons.eot 24 | docs\static\fonts\icons.svg 25 | docs\static\fonts\icons.ttf 26 | docs\static\fonts\icons.woff 27 | docs\static\source\data_translate.js 28 | docs\static\source\data_search.js 29 | docs\static\source\data_toc.js 30 | docs\static\source\data_index.js 31 | docs\static\source\data_deprecate.js 32 | NUL 33 | 34 | [INFOTYPES] 35 | -------------------------------------------------------------------------------- /docs/commands/ObjBindMethod.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Creates a BoundFunc object which calls a method of a given object.
16 | 17 |BoundFunc := ObjBindMethod(Obj, Method, Params)
18 |
19 | Any object.
A method name.
Any number of parameters.
For details and examples, see BoundFunc object.
35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/commands/WinMinimizeAll.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Minimizes or unminimizes all windows.
16 | 17 |18 | WinMinimizeAll 19 | WinMinimizeAllUndo 20 |21 |
On most systems, this is equivalent to Explorer's Win+M and Win+D hotkeys.
22 |Minimizes all windows for 1 second and unminimizes them.
27 |WinMinimizeAll 28 | Sleep, 1000 29 | WinMinimizeAllUndo30 |
Retrieves the name of a menu given a handle to its underlying Win32 menu.
17 |MenuName := MenuGetName(Handle)
18 |
19 | A Win32 menu handle (HMENU).
Only the menu's current handle is recognized. When the menu's underlying Win32 menu is destroyed and recreated, the handle changes. For details, see Win32 Menus.
29 | 30 |Returns a non-zero number if the specified value is an object.
16 | 17 |TrueOrFalse := IsObject(ObjectValue)
18 | A object stored in a variable, returned from a function, stored in another object or written directly.
This function returns 1 if ObjectValue is an object; otherwise 0.
28 | 29 |Reports "This is an object." because the value is an object.
34 |object := {key: "value"}
35 |
36 | if IsObject(object)
37 | MsgBox, This is an object.
38 | else
39 | MsgBox, This is not an object.
40 | Retrieves the title of the active window.
17 | 18 |WinGetActiveTitle, OutputVar
19 | The name of the variable in which to store the title of the active window.
This command is equivalent to: WinGetTitle, OutputVar, A.
WinGetPos, WinGetActiveStats, WinGetTitle, WinGetClass, WinGetText, ControlGetText
31 |Retrieves and reports the title of the active window.
34 |WinGetActiveTitle, Title 35 | MsgBox, The active window is "%Title%".36 |
[v1.1.09+]: This directive was removed. AutoIt scripts are no longer supported.
17 | 18 |Only for AutoIt v2 (.aut) scripts: Allows a comment to appear on the same line as a command.
19 | 20 |#AllowSameLineComments
21 | Specifying this directive at the top of any AutoIt v2 (.aut) script will enable the use of same-line comments, which are normally disabled for compatibility reasons. If not used at the top of the script, same-line comments are not supported above the point where the directive occurs.
22 |Like other directives, #AllowSameLineComments cannot be executed conditionally.
23 |Allows a comment to appear on the same line as a command.
26 |#AllowSameLineComments 27 | Sleep, 1 ; This comment is a same-line comment.28 |
Empties the recycle bin.
16 | 17 |FileRecycleEmpty , DriveLetter18 |
If omitted, the recycle bin for all drives is emptied. Otherwise, specify a drive letter such as C:\
[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.
28 |ErrorLevel is set to 1 if there was a problem or 0 otherwise.
29 |This commands requires that MS Internet Explorer 4 or later be installed.
31 |FileRecycle, FileDelete, FileCopy, FileMove
33 |Retrieves the free disk space of a drive, in Megabytes.
17 | 18 |DriveSpaceFree, OutputVar, Path
19 | The variable in which to store the result, which is rounded down to the nearest whole number.
Path of drive to receive information from. Since NTFS supports mounted volumes and directory junctions, different amounts of free space might be available in different folders of the same "drive" in some cases.
OutputVar is set to the amount of free disk space in Megabytes (rounded down to the nearest Megabyte).
32 |Retrieves the free disk space of the C drive and stores it in FreeSpace.
37 |DriveSpaceFree, FreeSpace, C:\38 |
Before AutoHotkey can do anything, you need to write a script telling it what to do.
35 | To learn how, read the tutorial or dive straight in.
Basically: create a script file → add some hotkeys → run the script file.
37 |You can also get help or find many useful scripts on our friendly discussion forum.
38 | 39 |You ran AutoHotkey without telling it which script file to run, and it couldn't find a script in either of the usual places.
42 |Notifies the OS and all running applications that environment variable(s) have changed.
17 | 18 |EnvUpdate
19 | [v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.
21 |ErrorLevel is set to 1 if there was a problem or 0 otherwise.
22 |Refreshes the OS environment. Similar effect as logging off and then on again.
24 |For example, after making changes to the following registry key, EnvUpdate could be used to broadcast the change:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment25 |
Returns a non-zero number if the specified ByRef parameter was supplied with a variable.
17 | 18 |TrueOrFalse := IsByRef(ParameterVar)
19 | A reference to the variable. For example: IsByRef(MyParameter).
This function returns 1 if ParameterVar is a ByRef parameter and the caller supplied a variable; or 0 if ParameterVar is any other kind of variable.
29 | 30 |Reports 1 (true) because Param is a ByRef parameter and was supplied with a variable.
35 |MsgBox, % Function(MyVar)
36 |
37 | Function(ByRef Param)
38 | {
39 | return IsByRef(Param)
40 | }
41 | Returns the numeric value of the first byte or UTF-16 code unit in the specified string.
17 | 18 |Number := Asc(String)
19 | The string whose numeric value is retrieved.
This function returns a numeric value in the range 0 to 255 (for ANSI) or 0 to 0xFFFF (for Unicode). See Unicode vs ANSI for details. If String is empty, it returns 0.
29 | 30 |This function is equivalent to Transform, OutputVar, Asc.
To allow for Unicode supplementary characters, use Ord(String) instead.
33 | 34 |Both message boxes below show 116, because only the first character is considered.
39 |MsgBox, % Asc("t")
40 | MsgBox, % Asc("test")
41 | Skips the gentle method of activating a window and goes straight to the forceful method.
16 | 17 |#WinActivateForce
18 | Specifying this anywhere in a script will cause commands that activate a window -- such as WinActivate, WinActivateBottom, and GroupActivate -- to skip the "gentle" method of activating a window and go straight to the more forceful methods.
19 |Although this directive will usually not change how quickly or reliably a window is activated, it might prevent task bar buttons from flashing when different windows are activated quickly one after the other.
20 | 21 |Like other directives, #WinActivateForce cannot be executed conditionally.
23 | 24 |WinActivate, WinActivateBottom, GroupActivate
26 |Trims characters from the beginning and/or end of a string.
16 | 17 |18 | Result := Trim(String, OmitChars := " `t") 19 | Result := LTrim(String, OmitChars := " `t") 20 | Result := RTrim(String, OmitChars := " `t") 21 |22 |
Any string value or variable. Numbers are not supported.
An optional list of characters (case sensitive) to exclude from the beginning and/or end of String. If omitted, spaces and tabs will be removed.
Trims all spaces from the left and right side of a string.
36 |text := " text " 37 | MsgBox % "No trim:`t '" text "'" 38 | . "`nTrim:`t '" Trim(text) "'" 39 | . "`nLTrim:`t '" LTrim(text) "'" 40 | . "`nRTrim:`t '" RTrim(text) "'"41 |
Creates a folder.
17 | 18 |FileCreateDir, DirName
19 | Name of the directory to create, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.
[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.
28 |ErrorLevel is set to 1 if there was a problem or 0 otherwise.
29 |A_LastError is set to the result of the operating system's GetLastError() function.
30 |Creates a new directory, including its parent directories if necessary.
37 |FileCreateDir, C:\Test1\My Images\Folder238 |
Retrieves the count of how many characters are in a string.
15 |Length := StrLen(String)
16 |
17 | This function returns the length of the string.
25 | 26 |If String is a variable to which ClipboardAll was previously assigned, StrLen() will retrieve its total size.
28 | 29 |StringLen, InStr(), SubStr(), Trim(), StringLower, StringUpper, StrPut(), StrGet(), StrReplace(), StrSplit()
31 | 32 |Retrieves and reports the count of how many characters are in a string.
35 |StrValue := "The quick brown fox jumps over the lazy dog" 36 | MsgBox % "The length of the string is " StrLen(StrValue) ; Result: 4337 |
Along with #MaxHotkeysPerInterval, specifies the rate of hotkey activations beyond which a warning dialog will be displayed.
17 | 18 |#HotkeyInterval Milliseconds
19 | The length of the interval in milliseconds.
If this directive is unspecified in the script, it will behave as though set to 2000.
28 |For details and remarks, see #MaxHotkeysPerInterval.
29 |Like other directives, #HotkeyInterval cannot be executed conditionally.
30 |Allows a maximum of 200 hotkeys to be pressed within 2000 ms without triggering a warning dialog.
35 |#HotkeyInterval 2000 ; This is the default value (milliseconds). 36 | #MaxHotkeysPerInterval 20037 |
Retrieves the value or pointer stored in a COM wrapper object.
16 | 17 |Value := ComObjValue(ComObject)
18 |
19 | A wrapper object containing a COM object or typed value.
This function returns a 64-bit signed integer.
29 | 30 |This function is not intended for general use.
32 |Calling ComObjValue is equivalent to variant.llVal, where ComObject is treated as a VARIANT structure. Any script which uses this function must be aware what type of value the wrapper object contains and how it should be treated. For instance, if an interface pointer is returned, Release should not be called, but AddRef may be required depending on what the script does with the pointer.
ComObjType(), ComObjCreate(), ComObjGet(), ComObjActive()
36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/commands/OutputDebug.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Sends a string to the debugger (if any) for display.
16 | 17 |OutputDebug, Text
18 | The text to send to the debugger for display. This text may include linefeed characters (`n) to start new lines. In addition, a single long line can be broken up into several shorter ones by means of a continuation section.
If the script's process has no debugger, the system debugger displays the string. If the system debugger is not active, this command has no effect.
28 |One example of a debugger is DebugView, which is free and available at microsoft.com.
29 |See also: other debugging methods
30 |FileAppend, continuation sections
32 |Sends a string to the debugger (if any) for display.
35 |OutputDebug, %A_Now%: Because the window "%TargetWindowTitle%" did not exist, the process was aborted.36 |
Returns the ordinal value (numeric character code) of the first character in the specified string.
16 | 17 |Number := Ord(String)
18 | The string whose ordinal value is retrieved.
This function returns the ordinal value of String, or 0 if String is empty. If String begins with a Unicode supplementary character, this function returns the corresponding Unicode character code (a number between 0x10000 and 0x10FFFF). Otherwise it returns a value in the range 0 to 255 (for ANSI) or 0 to 0xFFFF (for Unicode). See Unicode vs ANSI for details.
28 | 29 |Apart from the Unicode supplementary character detection, this function is identical to Asc().
31 | 32 |Both message boxes below show 116, because only the first character is considered.
37 |MsgBox, % Ord("t")
38 | MsgBox, % Ord("test")
39 | Retrieves a reference to a function.
17 | 18 |FunctionReference := Func(FunctionName)
19 | The name of the function whose reference is retrieved. FunctionName must exist explicitly in the script.
This function returns a reference to FunctionName. If FunctionName does not exist explicitly in the script (by means such as #Include or a non-dynamic call to a library function), it returns 0.
29 | 30 |This function can be used to call the function or retrieve information such as the minimum and maximum number of parameters.
32 | 33 |Function References, Func Object
35 |Retrieves a reference to a function and displays information about it.
38 |fn := Func("StrLen")
39 | MsgBox % fn.Name "() is " (fn.IsBuiltIn ? "built-in." : "user-defined.")
40 | Jumps to the specified label and continues execution.
16 | 17 |Goto, Label
18 | The name of the label to which to jump.
When using a dynamic label such as %MyLabel%, an error dialog will be displayed if the label does not exist. To avoid this, call IsLabel() beforehand. For example:
28 |if IsLabel(VarContainingLabelName) 29 | Goto %VarContainingLabelName%30 |
The use of Goto is discouraged because it generally makes scripts less readable and harder to maintain. Consider using Else, Blocks, Break, and Continue as substitutes for Goto.
31 |Gosub, Return, IsLabel(), Else, Blocks, Break, Continue, A_ThisLabel
33 |Jumps to the label named "MyLabel" and continues execution.
36 |Goto, MyLabel 37 | ; ... 38 | MyLabel: 39 | Sleep, 100 40 | ; ...41 |
Emits a tone from the PC speaker.
16 | 17 |SoundBeep , Frequency, Duration18 |
The frequency of the sound, which can be an expression. It should be a number between 37 and 32767. If omitted, the frequency will be 523.
The duration of the sound, in milliseconds (can be an expression). If omitted, the duration will be 150.
The script waits for the sound to finish before continuing. In addition, system responsiveness might be reduced during sound production.
31 |If the computer lacks a sound card, a standard beep is played through the PC speaker.
32 |To produce the standard system sounds instead of beeping the PC Speaker, see the asterisk mode of SoundPlay.
33 |Changes the script's comment symbol from semicolon to some other string.
17 |Deprecated: This directive is not recommended for use in new scripts. Use the default comment flag (semicolon) instead.
18 | 19 |#CommentFlag NewString
20 | One or more characters that should be used as the new comment flag. Up to 15 characters may be specified.
The default comment flag is semicolon (;).
29 |The comment flag is used to indicate that text that follows it should not be acted upon by the script (comments are not loaded into memory when a script is launched, so they do not affect performance).
30 |A comment flag that appears on the same line as a command is not considered to mark a comment unless it has at least one space or tab to its left. For example:
31 |MsgBox, Test1 ; This is a comment. 32 | MsgBox, Test2; This is not a comment and will be displayed by MsgBox.33 |
Like other directives, #CommentFlag cannot be executed conditionally.
34 |Disables the showing of a tray icon.
16 | 17 |#NoTrayIcon
18 | Specifying this anywhere in a script will prevent the showing of a tray icon for that script when it is launched (even if the script is compiled into an EXE).
19 |If you use this for a script that has hotkeys, you might want to bind a hotkey to the ExitApp command. Otherwise, there will be no easy way to exit the program (without restarting the computer or killing the process). For example: #x::ExitApp.
The tray icon can be made to disappear or reappear at any time during the execution of the script by using the command Menu, Tray, Icon or Menu, Tray, NoIcon. The only drawback of using Menu, Tray, NoIcon at the very top of the script is that the tray icon might be briefly visible when the script is first launched. To avoid that, use #NoTrayIcon instead.
The built-in variable A_IconHidden contains 1 if the tray icon is currently hidden or 0 otherwise.
22 |Like other directives, #NoTrayIcon cannot be executed conditionally.
23 |Checks which button was pushed by the user during the most recent MsgBox command.
17 | 18 |IfMsgBox, ButtonName
19 | One of the following strings to represent which button the user pressed in the most recent MsgBox command:
24 |Shows a yes-no message box which automatically stops execution after 5 seconds. The user can press the "No" button to initiate the stop immediately.
45 |MsgBox, 4, , Would you like to continue?, 5 ; 5-second timeout. 46 | IfMsgBox, No 47 | Return ; User pressed the "No" button. 48 | IfMsgBox, Timeout 49 | Return ; i.e. Assume "No" if it timed out. 50 | ; Otherwise, continue: 51 | ; ...52 |
Deletes a value from a standard format .ini file.
16 | 17 |IniDelete, Filename, Section , Key18 |
The name of the .ini file, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.
The section name in the .ini file, which is the heading phrase that appears in square brackets (do not include the brackets in this parameter).
The key name in the .ini file. If omitted, the entire Section will be deleted.
[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.
33 |ErrorLevel is set to 1 if there was a problem or 0 otherwise.
34 |A standard ini file looks like:
36 |[SectionName] 37 | Key=Value38 |
Deletes a key and its value located in section2 from a standard format .ini file.
43 |IniDelete, C:\Temp\myfile.ini, section2, key44 |
Retrieves the Win32 menu handle of a menu.
17 |Handle := MenuGetHandle(MenuName)
18 |
19 | The name of an existing menu. Menu names are not case sensitive.
The returned handle is valid only until the Win32 menu is destroyed. Once the menu is destroyed, the operating system may reassign the handle value to any menus subsequently created by the script or any other program. Conditions which can cause the menu to be destroyed are listed under Win32 Menus.
29 | 30 |Reports the number of items in a menu and the ID of the last item.
36 |Menu MyMenu, Add, Item 1, no
37 | Menu MyMenu, Add, Item 2, no
38 | Menu MyMenu, Add, Item B, no
39 |
40 | ; Retrieve the number of items in a menu.
41 | item_count := DllCall("GetMenuItemCount", "ptr", MenuGetHandle("MyMenu"))
42 |
43 | ; Retrieve the ID of the last item.
44 | last_id := DllCall("GetMenuItemID", "ptr", MenuGetHandle("MyMenu"), "int", item_count-1)
45 |
46 | MsgBox, MyMenu has %item_count% items, and its last item has ID %last_id%.
47 |
48 | no:
49 | return
50 |
51 | Checks for the existence of a file or folder.
17 |Deprecated: These commands are not recommended for use in new scripts. Use the FileExist function instead.
18 | 19 |20 | IfExist, FilePattern 21 | IfNotExist, FilePattern 22 |23 |
The path, filename, or file pattern to check. FilePattern is assumed to be in %A_WorkingDir% if an absolute path isn't specified.
FileExist(), Blocks, Else, File-loops
33 |Shows a message box if the D drive does exist.
36 |IfExist, D:\ 37 | MsgBox, The drive exists.38 |
Shows a message box if at least one text file does exist in a directory.
42 |IfExist, D:\Docs\*.txt 43 | MsgBox, At least one .txt file exists.44 |
Shows a message box if a file does not exist.
48 |IfNotExist, C:\Temp\FlagFile.txt 49 | MsgBox, The target file does not exist.50 |
Returns the string (usually a single character) corresponding to the character code indicated by the specified number.
16 | 17 |String := Chr(Number)
18 | If Unicode is supported, Number is a Unicode character code between 0 and 0x10FFFF (or 0xFFFF prior to [v1.1.21]); otherwise it is an ANSI character code between 0 and 255.
This function returns a string corresponding to Number. If Number is not in the valid range of character codes, an empty string is returned.
28 | 29 |This function supersedes Transform, OutputVar, Chr.
31 |The meaning of character codes greater than 127 depends on the string encoding in use, which in turn depends on whether a Unicode or ANSI executable is in use.
32 |Common character codes include 9 (tab), 10 (linefeed), 13 (carriage return), 32 (space), 48-57 (the digits 0-9), 65-90 (uppercase A-Z), and 97-122 (lowercase a-z).
33 | 34 |Reports the string corresponding to the character code 116.
40 |MsgBox % Chr(116) ; Reports "t".41 |
Terminates the script.
16 | 17 |ExitApp , ExitCode18 |
An integer between -2147483648 and 2147483647 (or [in v1.0.48.01+] an expression) that is returned to its caller when the script exits. This code is accessible to any program that spawned the script, such as another script (via RunWait) or a batch (.bat) file. If omitted, ExitCode defaults to zero. Zero is traditionally used to indicate success.
This is equivalent to choosing "Exit" from the script's tray menu or main menu.
28 |Any OnExit function or subroutine which has been registered by the script will be called automatically, and may prevent the script from terminating. In such a case, the current thread exits as if Exit was called.
29 |Terminating the script is not the same as exiting each thread. For instance, Finally blocks are not executed and __Delete is not called for objects contained by local variables.
30 | 31 |Exit, OnExit(), OnExit, #Persistent
33 | 34 |Sets the maximum number of keyboard and mouse events displayed by the KeyHistory window. You can set it to 0 to disable key history.
17 | 18 |#KeyHistory MaxEvents
19 | The maximum number of keyboard and mouse events displayed by the KeyHistory window (default 40, limit 500). Specify 0 to disable key history entirely.
Because this setting is put into effect before the script begins running, it is only necessary to specify it once (anywhere in the script).
28 |Because each keystroke or mouse click consists of a down-event and an up-event, KeyHistory displays only half as many "complete events" as specified here. For example, if the script contains #KeyHistory 50, up to 25 keystrokes and mouse clicks will be displayed.
Like other directives, #KeyHistory cannot be executed conditionally.
30 |Causes KeyHistory to display the last 100 instead 40 keyboard and mouse events.
35 |#KeyHistory 10036 |
Retrieves the name/text, virtual key code or scan code of a key.
17 | 18 |19 | String := GetKeyName(Key) 20 | Number := GetKeyVK(Key) 21 | Number := GetKeySC(Key) 22 |23 |
A VK or SC code, such as "vkA2" or "sc01D", a combination of both, or a key name. For example, both GetKeyName("vk1B") and GetKeyName("Esc") return Escape, while GetKeyVK("Esc") returns 27. Note that VK and SC codes must be in hexadecimal. To convert a decimal number to the appropriate format, use Format("vk{:x}", vk_code) or Format("sc{:x}", sc_code).
These functions return a name, virtual key code or scan code of Key.
33 | 34 |GetKeyState(), Key List, Format()
36 |Reports information for a specific key.
39 |key := "LWin" ; Any key can be used here.
40 |
41 | name := GetKeyName(key)
42 | vk := GetKeyVK(key)
43 | sc := GetKeySC(key)
44 |
45 | MsgBox, % Format("Name:`t{}`nVK:`t{:X}`nSC:`t{:X}", name, vk, sc)
46 | Retrieves the count of how many characters are in a string.
16 |Deprecated: This command is not recommended for use in new scripts. Use the StrLen function instead.
17 |StringLen, OutputVar, InputVar
18 |
19 | If InputVar is a variable to which ClipboardAll was previously assigned, StringLen will retrieve its total size.
32 | 33 |StrLen(), IfInString, StringGetPos, StringMid, StringTrimLeft, StringTrimRight, StringLeft, StringRight, StringLower, StringUpper, StringReplace
35 | 36 |Retrieves and reports the count of how many characters are in a string.
39 |StrValue := "The quick brown fox jumps over the lazy dog" 40 | StringLen, Length, StrValue 41 | MsgBox, The length of the string is %Length%.42 |
Retrieves the specified window's class name.
16 | 17 |WinGetClass, OutputVar , WinTitle, WinText, ExcludeTitle, ExcludeText18 |
The name of the variable in which to store the retrieved class name.
A window title or other criteria identifying the target window. See WinTitle.
If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.
Windows whose titles include this value will not be considered.
Windows whose text include this value will not be considered.
If there is no matching window, OutputVar is made blank.
40 |Only the class name is retrieved (the prefix "ahk_class" is not included in OutputVar).
41 |Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.
42 | 43 |Retrieves and reports the class name of the active window.
48 |WinGetClass, class, A 49 | MsgBox, The active window's class is "%class%".50 |
Returns a non-zero number if the specified function exists in the script.
17 | 18 |MinParamsPlus1 := IsFunc(FunctionName)
19 | The name of the function whose minimum number of parameters is retrieved. FunctionName must exist explicitly in the script. In [v1.1.00+], FunctionName can be a function reference instead of a name.
This function returns one plus the minimum number of parameters (e.g. 1 for a function that requires zero parameters, 2 for a function that requires 1 parameter, etc.). If FunctionName does not exist explicitly in the script (by means such as #Include or a non-dynamic call to a library function), it returns 0.
29 | 30 |Dynamically Calling a Function, Function References, Func Object, Func(), A_ThisFunc
32 |Reports the number of mandatory parameters of a function.
35 |count := IsFunc("RegExReplace") ; Any function name can be used here.
36 | if count
37 | MsgBox, % "This function exists and has " count-1 " mandatory parameters."
38 | else
39 | MsgBox, % "This function does not exist."
40 | Along with #HotkeyInterval, specifies the rate of hotkey activations beyond which a warning dialog will be displayed.
17 | 18 |#MaxHotkeysPerInterval Value
19 | The maximum number of hotkeys that can be pressed in the interval specified by #HotkeyInterval without triggering a warning dialog.
Care should be taken not to make the above too lenient because if you ever inadvertently introduce an infinite loop of keystrokes (via a Send command that accidentally triggers other hotkeys), your computer could become unresponsive due to the rapid flood of keyboard events.
28 |As an oversimplified example, the hotkey ^c::Send ^c would produce an infinite loop of keystrokes. To avoid this, add the $ prefix to the hotkey definition (e.g. $^c::) so that the hotkey cannot be triggered by the Send command.
If this directive is unspecified in the script, it will behave as though set to 70.
30 |Like other directives, #MaxHotkeysPerInterval cannot be executed conditionally.
31 |Allows to press a maximum of 200 instead of 70 hotkeys per interval.
36 |#MaxHotkeysPerInterval 20037 |
A macro is a series of scripted actions that is "played" upon demand. The most common activity of a macro is to send simulated keystrokes and mouse clicks to one or more windows. Such windows respond to each keystroke and mouse click as though you had performed it manually, which allows repetitive tasks to be automated with high speed and reliability.
17 |One of the most convenient ways to play back a macro is to assign it to a hotkey or hotstring. For example, the following hotkey would create an empty e-mail message and prepare it for a certain type recipient, allowing you to personalize it prior to sending:
18 |^!s:: ; Control+Alt+S hotkey.
19 | if not WinExist("Inbox - Microsoft Outlook")
20 | return ; Outlook isn't open to the right section, so do nothing.
21 | WinActivate ; Activate the window found by the above command.
22 | Send ^n ; Create new/blank e-mail via Control+N.
23 | WinWaitActive Untitled Message
24 | Send {Tab 2}Product Recall for ACME Rocket Skates ; Set the subject line.
25 | Send {Tab}Dear Sir or Madam,{Enter 2}We have recently discovered a minor defect ... ; etc.
26 | return ; This line serves to finish the hotkey.
27 | Hotkey macros like the above are especially useful for tasks you perform several times per day. By contrast, macros used less often can each be kept in a separate script accessible by means of a shortcut in the Start Menu or on the desktop.
28 |To start creating your own macros and hotkeys right away, please read the Quick-start Tutorial.
29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/commands/IsLabel.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Returns a non-zero number if the specified label exists in the script.
16 | 17 |TrueOrFalse := IsLabel(LabelName)
18 | The name of a subroutine, hotkey, or hotstring (do not include the trailing colon(s) in LabelName).
This function returns a non-zero number if LabelName exists in the script.
28 | 29 |This function is useful to avoid runtime errors when specifying a dynamic label in commands such as Gosub, Hotkey, Menu, and Gui.
31 |Reports "Subroutine exists" because the subroutine does exist.
36 |if IsLabel("Label")
37 | MsgBox, Subroutine exists
38 | else
39 | MsgBox, Subroutine doesn't exist
40 |
41 | Label:
42 | return
43 | Reports "Hotkey exists" because the hotkey does exist.
47 |if IsLabel("^#h")
48 | MsgBox, Hotkey exists
49 | else
50 | MsgBox, Hotkey doesn't exist
51 |
52 | ^#h::return
53 | Reports "Hotstring exists" because the hotstring does exist.
57 |if IsLabel("::btw")
58 | MsgBox, Hotstring exists
59 | else
60 | MsgBox, Hotstring doesn't exist
61 |
62 | ::btw::by the way
63 | Applies a condition to the continuation of a Loop or For-loop.
16 | 17 |18 | Loop { 19 | ... 20 | } Until Expression 21 |22 |
Any valid expression.
The expression is evaluated once after each iteration, and is evaluated even if continue was used. If the expression evaluates to false (which is an empty string or the number 0), the loop continues; otherwise, the loop is broken and execution continues at the line following Until.
32 |Loop Until is shorthand for the following:
33 |Loop {
34 | ...
35 | if (Expression)
36 | break
37 | }
38 | However, Loop Until is often easier to understand and unlike the above, can be used with a single-line action. For example:
39 |Loop 40 | x *= 2 41 | Until x > y42 |
Until can be used with any Loop or For. For example:
43 |Loop, Read, %A_ScriptFullPath% 44 | lines .= A_LoopReadLine . "`n" 45 | Until A_Index=5 ; Read the first five lines. 46 | MsgBox % lines 47 |48 |
If A_Index is used in Expression, it contains the index of the iteration which has just finished.
49 | 50 |Loop, While-loop, For-loop, Break, Continue, Blocks, Files-and-folders loop, Registry loop, File-reading loop, Parsing loop, If (expression)
52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /docs/commands/FileDelete.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Deletes one or more files.
16 | 17 |FileDelete, FilePattern
18 | The name of a single file or a wildcard pattern such as C:\Temp\*.tmp. FilePattern is assumed to be in %A_WorkingDir% if an absolute path isn't specified.
To remove an entire folder, along with all its sub-folders and files, use FileRemoveDir.
[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.
29 |ErrorLevel is set to the number of files that failed to be deleted (if any) or 0 otherwise. Deleting a wildcard pattern such as *.tmp is considered a success even if it does not match any files; thus ErrorLevel is set to 0.
If files were found, A_LastError is set to 0 (zero) or the result of the operating system's GetLastError() function immediately after the last failure. Otherwise A_LastError contains an error code that might indicate why no files were found.
31 | 32 |To delete a read-only file, first remove the read-only attribute. For example: FileSetAttrib, -R, C:\My File.txt.
FileRecycle, FileRemoveDir, FileCopy, FileMove
36 |You can disable all built-in Windows hotkeys except Win+L and Win+U by making the following change to the registry (this should work on all OSes but a reboot is probably required):
16 |HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer 17 | NoWinKeys REG_DWORD 0x00000001 (1)18 |
But read on if you want to do more than just disable them all.
19 |Hotkeys owned by another application can be overridden or disabled simply by assigning them to an action in the script. The most common use for this feature is to change the hotkeys that are built into Windows itself. For example, if you wish Win+E (the shortcut key that launches Windows Explorer) to perform some other action, use this:
20 |#e:: 21 | MsgBox This hotkey is now owned by the script. 22 | return23 |
In the next example, the Win+R hotkey, which is used to open the RUN window, is completely disabled:
24 |#r::return25 |
Similarly, to disable both Win, use this:
26 |LWin::return 27 | RWin::return28 |
To disable or change an application's non-global hotkey (that is, a shortcut key that only works when that application is the active window), consider the following example which disables Ctrl+P (Print) only for Notepad, leaving the key in effect for all other types of windows:
29 |$^p::
30 | if WinActive("ahk_class Notepad")
31 | return ; i.e. do nothing, which causes Control-P to do nothing in Notepad.
32 | Send ^p
33 | return
34 | In the above example, the $ prefix is needed so that the hotkey can "send itself" without activating itself (which would otherwise trigger a warning dialog about an infinite loop). See also: context-sensitive hotkeys.
35 |You can try out any of the above examples by copying them into a new text file such as "Override.ahk", then launching the file.
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/commands/WinShow.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Unhides the specified window.
16 | 17 |WinShow , WinTitle, WinText, ExcludeTitle, ExcludeText18 |
A window title or other criteria identifying the target window. See WinTitle.
If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.
Windows whose titles include this value will not be considered.
Windows whose text include this value will not be considered.
By default, WinShow is the only command that can always detect hidden windows. Other commands can detect them only if DetectHiddenWindows has been turned on.
37 |This command operates only upon the topmost matching window except when WinTitle is ahk_group GroupName, in which case all windows in the group are affected.
38 |WinHide, SetTitleMatchMode, DetectHiddenWindows, Last Found Window
40 |Opens Notepad, waits until it exists, hides it for a short time and unhides it.
43 |Run, notepad.exe 44 | WinWait, Untitled - Notepad 45 | Sleep, 500 46 | WinHide ; Use the window found by WinWait. 47 | Sleep, 1000 48 | WinShow ; Use the window found by WinWait.49 |
Changes the script's escape character (e.g. accent vs. backslash).
17 |Deprecated: This directive is not recommended for use in new scripts. Use the default escape character (accent/backtick) instead.
18 | 19 |#EscapeChar NewChar
20 | Specify a single character.
The escape character is used to indicate that the character immediately following it should be interpreted differently than it normally would.
29 |The default escape character is accent/backtick (`), which is at the upper left corner of most English keyboards. Using this character rather than backslash avoids the need for double blackslashes in file paths.
30 |See Escape Sequences for a complete list of sequences and its results (e.g. `n would produce a linefeed character).
Like other directives, #EscapeChar cannot be executed conditionally.
32 | 33 |The following rarely used directives also exist; their usage is shown in these examples:
35 |#DerefChar # ; Change it from its normal default, which is %. 36 | #Delimiter / ; Change it from its normal default, which is comma.37 |
Deprecated: These directives are not recommended for use in new scripts. Use the default dereference character (percent) and the default delimiter character (comma) instead.
38 |Sends a file or directory to the recycle bin if possible, or permanently deletes it.
16 | 17 |FileRecycle, FilePattern
18 | The name of a single file or a wildcard pattern such as C:\Temp\*.tmp. FilePattern is assumed to be in %A_WorkingDir% if an absolute path isn't specified.
23 |To recycle an entire directory, provide its name without a trailing backslash.
[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.
29 |ErrorLevel is set to 1 if there was a problem or 0 otherwise.
30 |SHFileOperation is used to do the actual work. This function may permanently delete the file if it is too large to be recycled; as of [v1.0.96], a warning should be shown before this occurs.
32 |The file may be permanently deleted without warning if the file cannot be recycled for other reasons, such as:
33 |NukeOnDelete registry value.FileRecycleEmpty, FileDelete, FileCopy, FileMove
39 |Sends all .tmp files in a directory to the recycle bin if possible.
42 |FileRecycle, C:\temp files\*.tmp43 |
Avoids checking empty variables to see if they are environment variables (recommended for all new scripts).
17 |#NoEnv
18 | Specifying the line #NoEnv anywhere in a script prevents empty variables from being looked up as potential environment variables. For example:
#NoEnv 20 | MsgBox %WinDir%21 |
The above would not retrieve the "WinDir" environment variable (though that could be solved by doing WinDir := A_WinDir near the top of the script).
Specifying #NoEnv is recommended for all new scripts because:
To help ease the transition to #NoEnv, the built-in variables ComSpec and ProgramFiles have been added. They contain the same strings as the corresponding environment variables.
29 |When #NoEnv is in effect, the script should use EnvGet to retrieve environment variables, or use built-in variables like A_WinDir.
30 |Like other directives, #NoEnv cannot be executed conditionally.
31 |EnvGet, ComSpec, ProgramFiles, A_WinDir
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /docs/commands/EnvGet.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Retrieves an environment variable.
16 | 17 |EnvGet, OutputVar, EnvVarName
18 | The name of the variable in which to store the string.
The name of the environment variable to retrieve. For example: EnvGet, OutputVar, Path.
If the specified environment variable is empty or does not exist, OutputVar is made blank.
30 |The operating system limits each environment variable to 32 KB of text.
31 |EnvSet, #NoEnv, environment variables, EnvUpdate, SetEnv, Run, RunWait
33 |Retrieves an environment variable and stores its value in OutputVar.
36 |EnvGet, OutputVar, LogonServer37 |
Retrieves and reports the path of the "Program Files" directory. See RegRead example #2 for an alternative method.
41 |EnvGet, OutputVar, % A_Is64bitOS ? "ProgramW6432" : "ProgramFiles" 42 | MsgBox, Program files are in: %OutputVar%43 |
Retrieves and reports the path of the current user's Local AppData directory.
47 |EnvGet, LocalAppData, LocalAppData 48 | MsgBox, %A_UserName%'s Local directory is located at: %LocalAppData%49 |
Unminimizes or unmaximizes the specified window if it is minimized or maximized.
16 | 17 |WinRestore , WinTitle, WinText, ExcludeTitle, ExcludeText18 |
A window title or other criteria identifying the target window. See WinTitle.
If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.
Windows whose titles include this value will not be considered.
Windows whose text include this value will not be considered.
If a particular type of window does not respond correctly to WinRestore, try using the following instead:
37 |PostMessage, 0x0112, 0xF120,,, WinTitle, WinText ; 0x0112 = WM_SYSCOMMAND, 0xF120 = SC_RESTORE38 |
This command operates only upon the topmost matching window except when WinTitle is ahk_group GroupName, in which case all windows in the group are affected.
39 |Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.
40 |Unminimizes or unmaximizes Notepad if it is minimized or maximized.
45 |WinRestore, Untitled - Notepad46 |
Sets a variable to itself times the given value. Synonymous with: Var *= Value.
Deprecated: This command is not recommended for use in new scripts. Use Var := Var * Value or Var *= Value instead.
EnvMult, Var, Value
20 | The name of the variable upon which to operate.
Any integer, floating point number, or expression.
This command is equivalent to the shorthand style: Var *= Value.
If either Var or Value is blank or does not start with a number, it is considered to be 0 for the purpose of the calculation (except when used internally in an expression such as Var := X *= Y).
If either Var or Value contains a decimal point, the end result will be a floating point number in the format set by SetFormat.
35 |EnvAdd, EnvSub, EnvDiv, SetFormat, Expressions, If var is [not] type, SetEnv, bitwise operations (Transform)
37 |Exits (terminates) any type of loop statement.
15 |Break , LoopLabel16 | 17 |
The use of Break and Continue are encouraged over Goto since they usually make scripts more readable and maintainable.
25 |Continue, Loop, While-loop, For-loop, Blocks, Labels
27 | 28 |Breaks the loop if var is greater than 25.
31 |Loop
32 | {
33 | ; ...
34 | if (var > 25)
35 | break
36 | ; ...
37 | if (var <= 5)
38 | continue
39 | }
40 | Breaks the outer loop from within a nested loop.
44 |outer:
45 | Loop 3
46 | {
47 | x := A_Index
48 | Loop 3
49 | {
50 | if (x*A_Index = 6)
51 | break outer ; Equivalent to break 2 or goto break_outer.
52 | MsgBox %x%,%A_Index%
53 | }
54 | }
55 | break_outer: ; For goto.
56 |
57 | Retrieves the title of the specified window.
16 | 17 |WinGetTitle, OutputVar , WinTitle, WinText, ExcludeTitle, ExcludeText18 |
The name of the variable in which to store the retrieved title.
A window title or other criteria identifying the target window. See WinTitle.
If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.
Windows whose titles include this value will not be considered.
Windows whose text include this value will not be considered.
If there is no matching window, OutputVar is made blank.
40 |To discover the name of the window that the mouse is currently hovering over, use MouseGetPos.
41 |Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.
42 |WinGetActiveStats, WinGetActiveTitle, WinGetClass, WinGet, WinGetText, ControlGetText, WinGetPos
44 |Retrieves and reports the title of the active window.
47 |WinGetTitle, Title, A 48 | MsgBox, The active window is "%Title%".49 |
Deletes a folder.
17 | 18 |FileRemoveDir, DirName , Recurse19 |
Name of the directory to delete, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.
This parameter determines whether to recurse into subdirectories. If omitted, it defaults to 0 (false). Specify one of the following values:
28 |0 (false): Do not remove files and sub-directories contained in DirName. In this case, if DirName is not empty, no action will be taken and ErrorLevel will be set to 1.
29 |1 (true): Remove all files and subdirectories (like the Windows command "rmdir /S").
30 |This parameter can be an expression, even one that evalutes to true or false (since true and false are stored internally as 1 and 0).
31 |[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.
36 |ErrorLevel is set to 1 if there was a problem or 0 otherwise.
37 | 38 |Removes the directory including its files and subdirectories.
48 |FileRemoveDir, C:\Download Temp, 149 |
Allows items in a collection to be enumerated.
16 | 17 |Retrieves the next item or items in an enumeration.
30 |Boolean := Enum.Next(OutputVar1 , OutputVar2, ...)31 |
This method returns 1 (true) if successful or 0 (false) if there were no items remaining.
38 |Enumerators returned by ObjNewEnum() are called once for each key-value pair, and allow up to two parameters:
39 |Key-value pairs are returned in an implementation-defined order. That is, they are typically not returned in the same order that they were assigned. Existing key-value pairs may be modified during enumeration, but inserting or removing keys may cause some items to be enumerated multiple times or not at all.
44 |Related: For-loop, Object.NewEnum()
45 |Examples:
46 |; Create some sample data.
47 | obj := Object("red", 0xFF0000, "blue", 0x0000FF, "green", 0x00FF00)
48 |
49 | ; Enumerate!
50 | enum := obj._NewEnum()
51 | While enum[k, v]
52 | t .= k "=" v "`n"
53 | MsgBox % t
54 |
55 | ; Requires [AHK_L 59+]
56 | For k, v in obj
57 | s .= k "=" v "`n"
58 | MsgBox % s
59 |
60 | Writes a value to a variable contained in the environment.
16 | 17 |EnvSet, EnvVar, Value
18 | Value to set the environment variable to.
[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.
31 |ErrorLevel is set to 1 if there was a problem or 0 otherwise.
32 |The operating system limits each environment variable to 32 KB of text.
34 |An environment variable created or changed with this command will be accessible only to programs the script launches via Run or RunWait. See environment variables for more details.
35 |This command exists separately from SetEnv because normal script variables are not stored in the environment. This is because performance would be worse and also because the OS limits environment variables to 32 KB.
36 |EnvGet, #NoEnv, environment variables, EnvUpdate, SetEnv, Run, RunWait
38 |Writes some text to the AutGUI variable contained in the environment.
41 |EnvSet, AutGUI, Some text to put in the variable.42 |
Creates a COM object.
16 |ComObject := ComObjCreate(CLSID , IID)17 | 18 |
CLSID or human-readable Prog ID of the COM object to create.
[v1.0.96.00+]: The identifier of an interface the object supports.
On failure, the function may throw an exception, exit the script or return an empty string, depending on the current ComObjError() setting and other factors.
31 |If an IID is specified, an interface pointer is returned. The script must typically call ObjRelease() when it is finished with the pointer.
32 |Otherwise, a wrapper object usable by script is returned. See object syntax.
33 | 34 |For a constantly growing list of examples, see the following forum topic: https://www.autohotkey.com/forum/topic61509.html.
39 |Launches an instance of Internet Explorer, makes it visible and navigates to a website.
41 |ie := ComObjCreate("InternetExplorer.Application")
42 | ie.Visible := true ; This is known to work incorrectly on IE7.
43 | ie.Navigate("https://www.autohotkey.com/")
44 |
45 | Increments or decrements an object's reference count.
17 | 18 |ObjAddRef(Ptr) 19 | ObjRelease(Ptr)20 | 21 |
An unmanaged object pointer or COM interface pointer.
These functions return the new reference count. This value should be used only for debugging purposes.
31 | 32 |Although the following articles discuss reference counting as it applies to COM, they cover some important concepts and rules which generally also apply to AutoHotkey objects: IUnknown::AddRef, IUnknown::Release, Reference Counting Rules.
35 | 36 |Retrieves the pointer of an object and increments the reference count. For details, see Pointers to Objects.
39 |obj := Object()
40 |
41 | ; The following two lines are equivalent:
42 | ptr1 := Object(obj)
43 | ptr2 := ObjectToPointer(obj)
44 |
45 | ObjectToPointer(obj) {
46 | if !IsObject(obj)
47 | return ""
48 | ptr := &obj
49 | ObjAddRef(ptr)
50 | return ptr
51 | }
52 |
53 | ; Each pointer retrieved via Object() or ObjectToPointer() must be manually released
54 | ; to allow the object to be eventually freed and any memory used by it reclaimed.
55 | ObjRelease(ptr2)
56 | ObjRelease(ptr1)
57 |
58 | For another example, see ComObjConnect().
61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /docs/commands/WinHide.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Hides the specified window.
16 | 17 |WinHide , WinTitle, WinText, ExcludeTitle, ExcludeText18 |
A window title or other criteria identifying the target window. See WinTitle.
If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.
Windows whose titles include this value will not be considered.
Windows whose text include this value will not be considered.
Use WinShow to unhide a hidden window (DetectHiddenWindows can be either On or Off to do this).
37 |This command operates only upon the topmost matching window except when WinTitle is ahk_group GroupName, in which case all windows in the group are affected.
38 |The Explorer taskbar may be hidden/shown as follows:
39 |WinHide ahk_class Shell_TrayWnd 40 | WinShow ahk_class Shell_TrayWnd41 |
WinShow, SetTitleMatchMode, DetectHiddenWindows, Last Found Window, WinSet
43 |Opens Notepad, waits until it exists, hides it for a short time and unhides it.
46 |Run, notepad.exe 47 | WinWait, Untitled - Notepad 48 | Sleep, 500 49 | WinHide ; Use the window found by WinWait. 50 | Sleep, 1000 51 | WinShow ; Use the window found by WinWait.52 |
Returns a reference to an object provided by a COM component.
15 |ComObject := ComObjGet(Name)
16 |
17 | The display name of the object to be retrieved. See MkParseDisplayName (MSDN) for more information.
On failure, the function may throw an exception, exit the script or return an empty string, depending on the current ComObjError() setting and other factors.
27 | 28 |Press Shift+Esc to show the command line which was used to launch the active window's process. Requires XP or later.
34 |+Esc::
35 | WinGet pid, PID, A
36 | ; Get WMI service object.
37 | wmi := ComObjGet("winmgmts:")
38 | ; Run query to retrieve matching process(es).
39 | queryEnum := wmi.ExecQuery(""
40 | . "Select * from Win32_Process where ProcessId=" . pid)
41 | ._NewEnum()
42 | ; Get first matching process.
43 | if queryEnum[proc]
44 | MsgBox 0, Command line, % proc.CommandLine
45 | else
46 | MsgBox Process not found!
47 | ; Free all global objects (not necessary when using local vars).
48 | wmi := queryEnum := proc := ""
49 | return
50 | ; Win32_Process: http://msdn.microsoft.com/en-us/library/aa394372.aspx
51 |
52 | Combines the functions of WinGetActiveTitle and WinGetPos into one command.
17 | 18 |WinGetActiveStats, Title, Width, Height, X, Y
19 | The name of the variable in which to store the title of the active window.
The names of the variables in which to store the width and height of the active window.
The names of the variables in which to store the X and Y coordinates of the active window's upper left corner.
If no matching window is found, the output variables will be made blank.
35 |This command is equivalent to the following sequence:
36 |WinGetTitle, Title, A 37 | WinGetPos, X, Y, Width, Height, A38 |
If the active window is a hidden window and DetectHiddenWindows is off (the default), all commands except WinShow will fail to "see" it. If there is no active window for this reason or any other, this command will set all of its output variables to be blank.
39 |WinGetPos, WinGetActiveTitle, WinGetTitle, WinGetClass, WinGetText, ControlGetText
41 |Retrieves and reports the title, size and position of the active window.
44 |WinGetActiveStats, Title, Width, Height, X, Y 45 | MsgBox, The active window "%Title%" is %Width% wide`, %Height% tall`, and positioned at %X%`,%Y%.46 |
Searching...
12 | 13 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/commands/FileEncoding.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Sets the default encoding for FileRead, FileReadLine, Loop Read, FileAppend, and FileOpen().
16 | 17 |FileEncoding , Encoding18 | 19 |
One of the following values (if omitted, it defaults to the system default ANSI code page, which is also the default setting):
24 |UTF-8: Unicode UTF-8, equivalent to CP65001.
25 |UTF-8-RAW: As above, but no byte order mark is written when a new file is created.
26 |UTF-16: Unicode UTF-16 with little endian byte order, equivalent to CP1200.
27 |UTF-16-RAW: As above, but no byte order mark is written when a new file is created.
28 |CPnnn: A code page with numeric identifier nnn. See Code Page Identifiers.
29 |A_FileEncoding contains the current setting.
Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).
35 |The default encoding is not used if a UTF-8 or UTF-16 byte order mark is present in the file, unless the file is being opened with write-only access (i.e. the previous contents of the file are being discarded).
36 | 37 |FileOpen(), StrGet(), StrPut(), Script Compatibility
39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /docs/static/source/data_deprecate.js: -------------------------------------------------------------------------------- 1 | deprecateData = { 2 | "commands/_CommentFlag.htm":"the default comment flag (semicolon)", 3 | "commands/_EscapeChar.htm":"the default escape character (accent)", 4 | "commands/_EscapeChar.htm#Delimiter":"the default delimiter character (comma)", 5 | "commands/_EscapeChar.htm#DerefChar":"the default dereference character (percent)", 6 | "commands/EnvDiv.htm":"Var /= Value", 7 | "commands/EnvMult.htm":"Var *= Value", 8 | "commands/GetKeyState.htm#command":"GetKeyState()", 9 | "commands/IfEqual.htm":"If (expression)", 10 | "commands/IfExist.htm":"FileExist()", 11 | "commands/IfInString.htm":"InStr()", 12 | "commands/IfWinActive.htm":"WinActive()", 13 | "commands/IfWinExist.htm":"WinExist()", 14 | "commands/OnClipboardChange.htm#label":"OnClipboardChange()", 15 | "commands/OnExit.htm#command":"OnExit()", 16 | "commands/Progress.htm":"Gui", 17 | "commands/SetEnv.htm":"Var := Value", 18 | "commands/SetFormat.htm":"Format()", 19 | "commands/SplashTextOn.htm":"Gui", 20 | "commands/StringGetPos.htm":"InStr()", 21 | "commands/StringLeft.htm":"SubStr()", 22 | "commands/StringLen.htm":"StrLen()", 23 | "commands/StringMid.htm":"SubStr()", 24 | "commands/StringReplace.htm":"StrReplace()", 25 | "commands/StringSplit.htm":"StrSplit()", 26 | "commands/StringTrimLeft.htm":"SubStr()", 27 | "commands/Transform.htm": "math functions and operators", 28 | "commands/Transform.htm#Abs": "Abs()", 29 | "commands/Transform.htm#ACos": "ACos()", 30 | "commands/Transform.htm#Asc": "Asc()", 31 | "commands/Transform.htm#ASin": "ASin()", 32 | "commands/Transform.htm#ATan": "ATan()", 33 | "commands/Transform.htm#BitAnd": "the & operator", 34 | "commands/Transform.htm#BitNot": "the ~ operator", 35 | "commands/Transform.htm#BitOr": "the | operator", 36 | "commands/Transform.htm#BitShiftLeft": "the << operator", 37 | "commands/Transform.htm#BitShiftRight": "the >> operator", 38 | "commands/Transform.htm#BitXOr": "the ^ operator", 39 | "commands/Transform.htm#Ceil": "Ceil()", 40 | "commands/Transform.htm#Chr": "Chr()", 41 | "commands/Transform.htm#Cos": "Cos()", 42 | "commands/Transform.htm#Deref": "the expression syntax or a custom function", 43 | "commands/Transform.htm#Exp": "Exp()", 44 | "commands/Transform.htm#Floor": "Floor()", 45 | "commands/Transform.htm#HTML": "a custom function", 46 | "commands/Transform.htm#Ln": "Ln()", 47 | "commands/Transform.htm#Log": "Log()", 48 | "commands/Transform.htm#Mod": "Mod()", 49 | "commands/Transform.htm#Pow": "the ** operator", 50 | "commands/Transform.htm#Round": "Round()", 51 | "commands/Transform.htm#Sin": "Sin()", 52 | "commands/Transform.htm#Sqrt": "Sqrt()", 53 | "commands/Transform.htm#Tan": "Tan()", 54 | "commands/Transform.htm#Unicode": "the Unicode version of AutoHotkey" 55 | }; 56 | -------------------------------------------------------------------------------- /docs/commands/_MaxMem.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Sets the maximum capacity of each variable to the specified number of megabytes.
17 | 18 |#MaxMem Megabytes
19 | The number of megabytes to allow for each variable. A value larger than 4095 is considered to be 4095. A value less than 1 is considered to be 1.
If this directive is unspecified in the script, it will behave as though set to 64.
28 |The purpose of limiting each variable's capacity is to prevent a buggy script from consuming all available system memory. Raising or lowering the limit does not affect the performance of a script, nor does it change how much memory the script actually uses (except in the case of WinGetText and ControlGetText, which will be capable of retrieving more text if #MaxMem is increased).
29 |This setting is global, meaning that it needs to be specified only once (anywhere in the script) to affect the behavior of the entire script.
30 |This setting restricts only the automatic expansion that a variable does on its own. It does not affect VarSetCapacity().
31 |Like other directives, #MaxMem cannot be executed conditionally.
32 |VarSetCapacity(), Variables, Sort, WinGetText, ControlGetText, #MaxThreads
34 |Forces the unconditional installation of the mouse hook.
17 | 18 |#InstallMouseHook
19 | The mouse hook monitors mouse clicks for the purpose of activating mouse hotkeys and facilitating hotstrings.
21 |AutoHotkey does not install the keyboard and mouse hooks unconditionally because together they consume at least 500 KB of memory (but if the keyboard hook is installed, installing the mouse hook only requires about 50 KB of additional memory; and vice versa). Therefore, the mouse hook is normally installed only when the script contains one or more mouse hotkeys. It is also installed for hotstrings, but that can be disabled via #Hotstring NoMouse.
22 |By contrast, the #InstallMouseHook directive will unconditionally install the mouse hook, which might be useful to allow KeyHistory to monitor mouse clicks.
23 |You can determine whether a script is using the hook via the KeyHistory command or menu item. You can determine which hotkeys are using the hook via the ListHotkeys command or menu item.
24 |This directive also makes a script persistent, meaning that ExitApp should be used to terminate it.
25 |Like other directives, #InstallMouseHook cannot be executed conditionally.
26 |#InstallKeybdHook, #UseHook, Hotkey, #Persistent, KeyHistory, GetKeyState(), KeyWait
28 |Retrieves the version of a file.
16 | 17 |FileGetVersion, OutputVar , Filename18 |
The name of the variable in which to store the version number/string.
The name of the target file. If a full path is not specified, this function uses the search sequence specified by the system LoadLibrary function. If omitted, the current file of the innermost enclosing File-Loop will be used instead.
[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.
31 |ErrorLevel is set to 1 if there was a problem or 0 otherwise.
32 |A_LastError is set to the result of the operating system's GetLastError() function.
33 | 34 |Most non-executable files (and even some EXEs) won't have a version, and thus OutputVar will be blank in these cases.
36 |FileGetAttrib, FileSetAttrib, FileGetTime, FileSetTime, FileGetSize, File-loop
38 |Retrieves the version of a file and stores it in Version.
41 |FileGetVersion, Version, C:\My Application.exe42 |
Retrieves the version of the file "AutoHotkey.exe" located in AutoHotkey's installation directory and stores it in Version.
46 |FileGetVersion, Version, %A_ProgramFiles%\AutoHotkey\AutoHotkey.exe47 |
Controls which artificial keyboard and mouse events are ignored by hotkeys and hotstrings.
15 |#InputLevel Level16 | 17 |
An integer between 0 and 100. If omitted, it defaults to 0.
For an explanation of how SendLevel and #InputLevel are used, see SendLevel.
27 |This directive is positional: it affects all hotkeys and hotstrings between it and the next #InputLevel directive. If not specified by an #InputLevel directive, hotkeys and hotstrings default to level 0.
28 |[v1.1.23+]: A hotkey's input level can also be set using the Hotkey command. For example: Hotkey, #z, my_hotkey_sub, I1
The input level of a hotkey or non-auto-replace hotstring is also used as the default send level for any keystrokes or button clicks generated by that hotkey or hotstring. Since a keyboard or mouse remapping is actually a pair of hotkeys, this allows #InputLevel to be used to allow remappings to trigger other hotkeys.
30 |AutoHotkey versions older than [v1.1.06] behave as though #InputLevel 0 and SendLevel 0 are in effect.
31 |Like other directives, #InputLevel cannot be executed conditionally.
32 | 33 |SendLevel, Hotkeys, Hotstrings
35 | 36 | Causes the first hotkey Numpad0:: to trigger the second hotkey ~LButton::. This would be not the case if the #InputLevel directives are omitted or commented out.
40 | #InputLevel 1 41 | Numpad0::LButton 42 | #InputLevel 0 43 | ; This hotkey can be triggered by both Numpad0 and LButton: 44 | ~LButton::MsgBox Clicked 45 |46 |
Sets a variable to itself divided by the given value. Synonymous with: Var /= Value.
Deprecated: This command is not recommended for use in new scripts. Use Var := Var / Value or Var /= Value instead.
EnvDiv, Var, Value
20 | The name of the variable upon which to operate.
Any integer, floating point number, or expression.
This command is equivalent to the shorthand style: Var /= Value.
Division by zero will result in an error-message window when the script is loaded (if possible); otherwise it makes the variable blank.
34 |If either Var or Value is blank or does not start with a number, it is considered to be 0 for the purpose of the calculation (except when used internally in an expression such as Var := X /= Y).
If either Var or Value contains a decimal point, the end result will be a floating point number in the format set by SetFormat. Otherwise, the result will be truncated (e.g. 19 divided by 10 will yield 1).
36 |EnvAdd, EnvSub, EnvMult, SetFormat, Expressions, If var is [not] type, SetEnv, bitwise operations (Transform)
38 |Determines whether invisible text in a window is "seen" for the purpose of finding the window. This affects commands, built-in functions and control flow statements such as WinExist() and WinActivate.
16 | 17 |DetectHiddenText, OnOff
18 | On: This is the default. Hidden text will be detected.
23 |Off: Hidden text is not detected.
24 |[v1.1.30+]: The decimal values 1 and 0 may be used in place of On and Off, respectively.
25 |"Hidden text" is a term that refers to those controls of a window that are not visible. Their text is thus considered "hidden". Turning off DetectHiddenText can be useful in cases where you want to detect the difference between the different panes of a multi-pane window or multi-tabbed dialog. Use Window Spy to determine which text of the currently-active window is hidden. All commands, built-in functions and control flow statements that accept a WinText parameter are affected by this setting, including WinActivate, WinActive(), IfWinActive, WinWait, WinExist(), and IfWinExist.
31 |The built-in variable A_DetectHiddenText contains the current setting (On or Off).
32 |Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).
33 |Sets the maximum time that may be spent evaluating a single #If expression.
18 | 19 |#IfTimeout Timeout
20 | The timeout value to apply globally, in milliseconds.
A timeout is implemented to prevent long-running expressions from stalling keyboard input processing. If the timeout value is exceeded, the expression continues to evaluate, but the keyboard hook continues as if the expression had already returned false.
30 |If this directive is unspecified in the script, it will behave as though set to 1000.
31 |Note that the system implements its own timeout, defined by the DWORD value LowLevelHooksTimeout in the following registry key:
32 |HKEY_CURRENT_USER\Control Panel\Desktop
33 |If the system timeout value is exceeded, the system may stop calling the script's keyboard hook, thereby preventing hook hotkeys from working until the hook is re-registered or the script is reloaded. The hook can usually be re-registered by suspending and un-suspending all hotkeys.
34 |Microsoft's documentation is unclear about the details of this timeout, but research indicates the following for Windows 7 and later: If LowLevelHooksTimeout is not defined, the default timeout is 300ms. The hook may time out up to 10 times, but is silently removed if it times out an 11th time.
35 |If a given hotkey has multiple #If variants, the timeout might be applied to each variant independently, making it more likely that the system timeout will be exceeded. This may be changed in a future update.
36 |Like other directives, #IfTimeout cannot be executed conditionally.
37 |This section demonstrates how to control Winamp via hotkey even when it is minimized or inactive. This information has been tested with Winamp 2.78c but should work for other major releases as well. Please post changes and improvements in the forum or contact the author.
16 |This example makes the Ctrl+Alt+P hotkey equivalent to pressing Winamp's pause/unpause button:
17 |^!p::
18 | if not WinExist("ahk_class Winamp v1.x")
19 | return
20 | ; Otherwise, the above has set the "last found" window for use below.
21 | ControlSend, ahk_parent, c ; Pause/Unpause
22 | return
23 | Here are some of the keyboard shortcuts available in Winamp 2.x (may work in other versions too). The above example can be revised to use any of these keys:
24 || Key to send | 27 |Effect | 28 |
|---|---|
c |
31 | Pause/UnPause | 32 |
x |
35 | Play/Restart/UnPause | 36 |
v |
39 | Stop | 40 |
+v |
43 | Stop with Fadeout | 44 |
^v |
47 | Stop after the current track | 48 |
b |
51 | Next Track | 52 |
z |
55 | Previous Track | 56 |
{left} |
59 | Rewind 5 seconds | 60 |
{right} |
63 | Fast-forward 5 seconds | 64 |
{up} |
67 | Turn Volume Up | 68 |
{down} |
71 | Turn Volume Down | 72 |
The following example asks Winamp which track number is currently active:
75 |
76 | SendMessage, 0x0400, 0, 120,, ahk_class Winamp v1.x
77 | if (ErrorLevel != "FAIL")
78 | {
79 | ErrorLevel += 1 ; Winamp's count starts at 0, so adjust by 1.
80 | MsgBox, Track #%ErrorLevel% is active or playing.
81 | }
82 |
83 |
84 |
--------------------------------------------------------------------------------
/docs/commands/_ClipboardTimeout.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Changes how long the script keeps trying to access the clipboard when the first attempt fails.
16 | 17 |#ClipboardTimeout Milliseconds
18 | The length of the interval in milliseconds. Specify -1 to have it keep trying indefinitely. Specify 0 to have it try only once. Scripts that do not contain this directive use a 1000 ms timeout.
Some applications keep the clipboard open for long periods of time, perhaps to write or read large amounts of data. In such cases, increasing this setting causes the script to wait longer before giving up and displaying an error message.
27 |This settings applies to all clipboard operations, the simplest of which are the following examples: Var := Clipboard and Clipboard := "New Text".
Whenever the script is waiting for the clipboard to become available, new threads cannot be launched and timers will not run. However, if the user presses a hotkey, selects a custom menu item, or performs a GUI action such as pressing a button, that event will be buffered until later; in other words, its subroutine will be performed after the clipboard finally becomes available.
29 |This directive does not cause the reading of clipboard data to be reattempted if the first attempt fails. Prior to [v1.1.16], it did cause the script to wait until the timeout expired, but in doing so prevented any further data from being retrieved.
30 |Like other directives, #ClipboardTimeout cannot be executed conditionally.
31 |Causes the script to wait 2 seconds instead of 1 second before giving up accessing the clipboard and displaying an error message.
36 |#ClipboardTimeout 200037 |
Displays the hotkeys in use by the current script, whether their subroutines are currently running, and whether or not they use the keyboard or mouse hook.
16 | 17 |ListHotkeys
18 | This command is equivalent to selecting the View->Hotkeys menu item in the main window.
19 |If a hotkey has been disabled via the Hotkey command, it will be listed as OFF or PART ("PART" means that only some of the hotkey's variants are disabled).
20 |[v1.1.16+]: If any of a hotkey's variants have a non-zero #InputLevel, the level (or minimum and maximum levels) are displayed.
21 |If any of a hotkey's subroutines are currently running, the total number of threads is displayed for that hotkey.
22 |Finally, the type of hotkey is also displayed, which is one of the following:
23 |#InstallKeybdHook, #InstallMouseHook, #UseHook, KeyHistory, ListLines, ListVars, #MaxThreadsPerHotkey, #MaxHotkeysPerInterval
34 |Enlarges the specified window to its maximum size.
16 | 17 |WinMaximize , WinTitle, WinText, ExcludeTitle, ExcludeText18 |
A window title or other criteria identifying the target window. See WinTitle.
If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.
Windows whose titles include this value will not be considered.
Windows whose text include this value will not be considered.
Use WinRestore to unmaximize a window and WinMinimize to minimize it.
37 |If a particular type of window does not respond correctly to WinMaximize, try using the following instead:
38 |PostMessage, 0x0112, 0xF030,,, WinTitle, WinText ; 0x0112 = WM_SYSCOMMAND, 0xF030 = SC_MAXIMIZE39 |
This command operates only upon the topmost matching window except when WinTitle is ahk_group GroupName, in which case all windows in the group are affected.
40 |Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.
41 |Opens Notepad, waits until it exists and maximizes it.
46 |Run, notepad.exe 47 | WinWait, Untitled - Notepad 48 | WinMaximize ; Use the window found by WinWait.49 |
Retrieves the wave output volume of a sound device.
17 | 18 |SoundGetWaveVolume, OutputVar , DeviceNumber19 |
The name of the variable in which to store the retrieved volume level, which is a floating point number between 0 and 100 inclusive. The variable will be made blank if there was a problem retrieving the volume. The format of the floating point number, such as its decimal places, is determined by SetFormat.
If this parameter is omitted, it defaults to 1 (the first sound device), which is usually the system's default device for recording and playback. Specify a number higher than 1 to operate upon a different sound device.
[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.
31 |ErrorLevel is set to 1 if there was a problem or 0 otherwise.
32 |The current wave output volume level can be set via SoundSetWaveVolume. Settings such as Master Volume, Synth, Microphone, Mute, Treble, and Bass can be set and retrieved using SoundSet and SoundGet.
34 |[v1.1.10+]: On Windows Vista and later, this command is equivalent to SoundGet with ComponentType set to Wave and ControlType set to Volume.
SoundSetWaveVolume, SoundSet, SoundGet, SoundPlay
37 |Retrieves and reports the current wave output volume.
40 |SoundGetWaveVolume, OutputVar 41 | MsgBox, The current wave output volume level is %OutputVar%`%.42 |
Shuts down, restarts, or logs off the system.
16 | 17 |Shutdown, Flag
18 | A combination (sum) of the following numbers:
24 |Add the required values together. For example, to shutdown and power down the flag would be 9 (shutdown + power down = 1 + 8 = 9). Alternatively, an expression such as 1+8 can be specified.
32 |The "Force" value (4) forces all open applications to close. It should only be used in an emergency because it may cause any open applications to lose data.
33 |The "Power down" value (8) shuts down the system and turns off the power.
34 |To have the system suspend or hibernate, see example #2 at the bottom of this page.
40 |To turn off the monitor, see PostMessage example #1.
41 |On a related note, a script can detect when the system is shutting down or the user is logging off via OnExit() or OnExit.
42 |Run, ExitApp, OnExit(), OnExit
44 |Calls the Windows API function "SetSuspendState" to have the system suspend or hibernate. Note that the second parameter may have no effect at all on newer systems.
52 |; Parameter #1: Pass 1 instead of 0 to hibernate rather than suspend.
53 | ; Parameter #2: Pass 1 instead of 0 to suspend immediately rather than asking each application for permission.
54 | ; Parameter #3: Pass 1 instead of 0 to disable all wake events.
55 | DllCall("PowrProf\SetSuspendState", "Int", 0, "Int", 0, "Int", 0)
56 | Changes the title of the specified window.
16 | 17 |18 | WinSetTitle, NewTitle 19 | WinSetTitle, WinTitle, WinText, NewTitle , ExcludeTitle, ExcludeText 20 |21 |
The new title for the window. If this is the only parameter given, the Last Found Window will be used.
A window title or other criteria identifying the target window. See WinTitle.
If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.
Windows whose titles include this value will not be considered.
Windows whose text include this value will not be considered.
A change to a window's title might be merely temporary if the application that owns the window frequently changes the title.
43 |Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.
44 |WinMove, WinGetActiveStats, WinGetActiveTitle, WinGetText, ControlGetText, WinGetPos, WinSet
46 |Opens Notepad, waits until it is active and changes its title.
54 |Run, notepad.exe 55 | WinWaitActive, Untitled - Notepad 56 | WinSetTitle, This is a new title ; Use the window found by WinWaitActive.57 |
Exits the current thread or (if the script is not persistent) the entire script.
16 | 17 |Exit , ExitCode18 |
An integer between -2147483648 and 2147483647 (can be an expression) that is returned to its caller when the script exits. This code is accessible to any program that spawned the script, such as another script (via RunWait) or a batch (.bat) file. If omitted, ExitCode defaults to zero. Zero is traditionally used to indicate success.
If the script is not persistent, Exit will attempt to terminate the entire script as though ExitApp was called.
28 |If the script is not terminated, the Exit command terminates the current thread. In other words, the stack of subroutines called directly or indirectly by a menu, timer, or hotkey subroutine will all be returned from as though a Return were immediately encountered in each. If used directly inside such a subroutine -- rather than in one of the subroutines called indirectly by it -- Exit is equivalent to Return.
29 |Use ExitApp to completely terminate a script that is persistent.
30 | 31 |ExitApp, OnExit(), OnExit, Functions, Gosub, Return, Threads, #Persistent
33 |In this example, the Exit command terminates the Sub2 subroutine as well as the calling subroutine.
36 |#z:: 37 | Gosub, Sub2 38 | MsgBox, This MsgBox will never happen because of the EXIT. 39 | return 40 | 41 | Sub2: 42 | Exit ; Terminate this subroutine as well as the calling subroutine.43 |