├── .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 | Redirection 8 | 9 | 10 |

Redirecting to AutoHotkey.htm.

11 | 12 | -------------------------------------------------------------------------------- /docs/scripts/WinLIRC.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to WinLIRC Client.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/Numpad000.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to Numpad 000 Key.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/IntelliSense.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to IntelliSense.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/JoystickTest.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to Joystick Test Script.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/MouseGestures.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to Mouse Gestures.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/VolumeOSD.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to Volume On-Screen-Display (OSD).

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/WindowShading.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to Window Shading.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/EasyWindowDrag.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to Easy Window Dragging.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/JoystickMouse.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to Using a Joystick as a Mouse.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/KeyboardOnScreen.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to On-Screen Keyboard.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/TooltipMouseMenu.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to ToolTip Mouse Menu.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/FavoriteFolders.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to Easy Access to Favorite Folders.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/NumpadMouse.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to Using Keyboard Numpad as a Mouse.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/MinimizeToTrayMenu.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to Minimize Window to Tray Menu.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/MsgBoxButtonNames.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to Changing MsgBox's Button Names.

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/EasyWindowDrag_(KDE).htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

Redirecting to Easy Window Dragging (KDE style).

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/scripts/ContextSensitiveHelp.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirection 9 | 10 | 11 | 12 |

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 | Redirection 9 | 10 | 11 | 12 |

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 | ObjBindMethod() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

ObjBindMethod() [v1.1.20+]

14 | 15 |

Creates a BoundFunc object which calls a method of a given object.

16 | 17 |
BoundFunc := ObjBindMethod(Obj, Method, Params)
18 | 19 |

Parameters

20 |
21 | 22 |
Obj
23 |

Any object.

24 | 25 |
Method
26 |

A method name.

27 | 28 |
Params
29 |

Any number of parameters.

30 | 31 |
32 | 33 |

Remarks

34 |

For details and examples, see BoundFunc object.

35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/commands/WinMinimizeAll.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinMinimizeAll / WinMinimizeAllUndo - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

WinMinimizeAll / WinMinimizeAllUndo

14 | 15 |

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 | 23 |

WinMinimize, GroupAdd

24 |

Examples

25 |
26 |

Minimizes all windows for 1 second and unminimizes them.

27 |
WinMinimizeAll
28 | Sleep, 1000
29 | WinMinimizeAllUndo
30 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/commands/MenuGetName.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | MenuGetName() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

MenuGetName() [v1.1.23+]

15 | 16 |

Retrieves the name of a menu given a handle to its underlying Win32 menu.

17 |
MenuName := MenuGetName(Handle)
18 | 19 |

Parameters

20 |
21 | 22 |
Handle
23 |

A Win32 menu handle (HMENU).

24 | 25 |
26 | 27 |

Remarks

28 |

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 | 31 |

Menu, MenuGetHandle()

32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /docs/static/source/check_data.ahk: -------------------------------------------------------------------------------- 1 | ; Requires AutoHotkey v1.1 2 | 3 | SetWorkingDir %A_ScriptDir%\..\.. ; Required. 4 | 5 | if !RegExMatch(A_WorkingDir, "\\docs$") ; Sanity check. 6 | MsgBox 48,, Working dir is not \docs.`n%A_WorkingDir% 7 | 8 | file_indexed := {} 9 | 10 | ; Check for missing files and anchors referenced in the index. 11 | datafile := A_WorkingDir "\static\source\data_index.js" 12 | Loop Read, %datafile% 13 | { 14 | if RegExMatch(A_LoopReadLine, "O)\[""(.*?)"",""(.*?)""", m) 15 | { 16 | CheckHREF(m[1], m[2]) 17 | } 18 | } 19 | 20 | ; Check for missing files and anchors referenced in the TOC. 21 | datafile := A_WorkingDir "\static\source\data_toc.js" 22 | Loop Read, %datafile% 23 | { 24 | if RegExMatch(A_LoopReadLine, "O)\[""(.*?)"",""(.+?)""", m) 25 | { 26 | CheckHREF(m[1], m[2]) 27 | } 28 | } 29 | 30 | ; Check for files which aren't in the index or TOC. 31 | ; Note that some are intentionally omitted. 32 | if false 33 | Loop Files, *.htm, FR 34 | { 35 | path := A_LoopFileFullPath 36 | if !file_indexed[path] 37 | D("file not in index or TOC: " path) 38 | } 39 | 40 | CheckHREF(topic, href) 41 | { 42 | global file_indexed, datafile 43 | href := StrSplit(href, "#") 44 | FileRead html, % href[1] 45 | if ErrorLevel 46 | D(datafile " (" A_Index ") : " href[1]) 47 | else if href.length() != 1 && !InStr(html, "id=""" href[2] """") 48 | D(datafile " (" A_Index ") : #" href[2]) 49 | file_indexed[StrReplace(href[1],"/","\")] := true 50 | } 51 | 52 | D(s) { 53 | FileAppend %s%`n, * 54 | } -------------------------------------------------------------------------------- /docs/commands/IsObject.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IsObject() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

IsObject() [v1.0.90+]

14 | 15 |

Returns a non-zero number if the specified value is an object.

16 | 17 |
TrueOrFalse := IsObject(ObjectValue)
18 |

Parameters

19 |
20 | 21 |
ObjectValue
22 |

A object stored in a variable, returned from a function, stored in another object or written directly.

23 | 24 |
25 | 26 |

Return Value

27 |

This function returns 1 if ObjectValue is an object; otherwise 0.

28 | 29 | 30 |

Objects

31 |

Examples

32 |
33 |

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 |
41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/commands/WinGetActiveTitle.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinGetActiveTitle - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

WinGetActiveTitle

15 | 16 |

Retrieves the title of the active window.

17 | 18 |
WinGetActiveTitle, OutputVar
19 |

Parameters

20 |
21 | 22 |
OutputVar
23 |

The name of the variable in which to store the title of the active window.

24 | 25 |
26 | 27 |

Remarks

28 |

This command is equivalent to: WinGetTitle, OutputVar, A.

29 | 30 |

WinGetPos, WinGetActiveStats, WinGetTitle, WinGetClass, WinGetText, ControlGetText

31 |

Examples

32 |
33 |

Retrieves and reports the title of the active window.

34 |
WinGetActiveTitle, Title
35 | MsgBox, The active window is "%Title%".
36 |
37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/commands/_AllowSameLineComments.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #AllowSameLineComments - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

#AllowSameLineComments

15 | 16 |

[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 |

Examples

24 |
25 |

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 |
29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/static/source/data_translate.js: -------------------------------------------------------------------------------- 1 | translateData = { 2 | // sidebar 3 | "C̲ontent":true, 4 | "Content tab":true, 5 | "Shortcut: ALT+C":true, 6 | "In̲dex":true, 7 | "Index tab":true, 8 | "Shortcut: ALT+N":true, 9 | "Filter":true, 10 | "Directives":true, 11 | "Built-in Variables":true, 12 | "Built-in Functions":true, 13 | "Control Flow Statements":true, 14 | "Declarations":true, 15 | "Operators":true, 16 | "Commands":true, 17 | "Ahk2Exe Compiler":true, 18 | "S̲earch":true, 19 | "Search tab":true, 20 | "Shortcut: ALT+S":true, 21 | "Search":true, 22 | "Highlight keywords":true, 23 | "Go to previous/next occurrence":true, 24 | "Quick reference":true, 25 | "Collapse or uncollapse the quick reference":true, 26 | // header 27 | "Skip navigation":true, 28 | "Hide or show the sidebar":true, 29 | "Go to the homepage":true, 30 | "en":true, 31 | "Change the language":true, 32 | "v1":true, 33 | "Change the version":true, 34 | "Edit this document on GitHub":true, 35 | "https://github.com/Lexikos/AutoHotkey_L-Docs/edit/master/docs/":true, 36 | "Go back":true, 37 | "Go forward":true, 38 | "Change the font size":true, 39 | "Print this document":true, 40 | "Open this document in the default browser (requires internet connection). Middle-click to copy the link address.":true, 41 | "Use the dark or light theme":true, 42 | "Open the help settings":true, 43 | // ALT+... shortcuts (needs uppercase) 44 | "C":true, 45 | "N":true, 46 | "S":true, 47 | // content 48 | "Select code":true, 49 | "Download code":true, 50 | "Back to top":true, 51 | "Applies to:\nAutoHotkey_L Revision {0} and later\nAutoHotkey v1.0.90.00 and later":true, 52 | "Applies to AutoHotkey {0} and later":true, 53 | "Deprecated. New scripts should use {0} instead.":true 54 | }; 55 | -------------------------------------------------------------------------------- /docs/commands/FileRecycleEmpty.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FileRecycleEmpty - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

FileRecycleEmpty

14 | 15 |

Empties the recycle bin.

16 | 17 |
FileRecycleEmpty , DriveLetter
18 |

Parameters

19 |
20 | 21 |
DriveLetter
22 |

If omitted, the recycle bin for all drives is emptied. Otherwise, specify a drive letter such as C:\

23 | 24 |
25 | 26 |

Error Handling

27 |

[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 |

Remarks

30 |

This commands requires that MS Internet Explorer 4 or later be installed.

31 | 32 |

FileRecycle, FileDelete, FileCopy, FileMove

33 |

Examples

34 |
35 |

Empties the recycle bin of the C drive.

36 |
FileRecycleEmpty, C:\
37 |
38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/commands/DriveSpaceFree.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DriveSpaceFree - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

DriveSpaceFree

15 | 16 |

Retrieves the free disk space of a drive, in Megabytes.

17 | 18 |
DriveSpaceFree, OutputVar, Path
19 |

Parameters

20 |
21 | 22 |
OutputVar
23 |

The variable in which to store the result, which is rounded down to the nearest whole number.

24 | 25 |
Path
26 |

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.

27 | 28 |
29 | 30 |

Remarks

31 |

OutputVar is set to the amount of free disk space in Megabytes (rounded down to the nearest Megabyte).

32 | 33 |

Drive, DriveGet

34 |

Examples

35 |
36 |

Retrieves the free disk space of the C drive and stores it in FreeSpace.

37 |
DriveSpaceFree, FreeSpace, C:\
38 |
39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /docs/Welcome.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Welcome to AutoHotkey 7 | 8 | 9 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |

Welcome...

32 | 33 |

Getting Started

34 |

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.

36 |

Basically: create a script fileadd some hotkeys → run the script file.

37 |

You can also get help or find many useful scripts on our friendly discussion forum.

38 | 39 |

Why am I seeing this?

40 |
41 |

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 |
43 | 44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /docs/commands/EnvUpdate.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EnvUpdate - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

EnvUpdate

15 | 16 |

Notifies the OS and all running applications that environment variable(s) have changed.

17 | 18 |
EnvUpdate
19 |

Error Handling

20 |

[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 |

Remarks

23 |

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\Environment

25 | 26 |

EnvSet, RegWrite

27 |

Examples

28 |
29 |

Refreshes the OS environment.

30 |
EnvUpdate
31 |
32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /docs/commands/IsByRef.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IsByRef() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

IsByRef() [v1.1.01+]

15 | 16 |

Returns a non-zero number if the specified ByRef parameter was supplied with a variable.

17 | 18 |
TrueOrFalse := IsByRef(ParameterVar)
19 |

Parameters

20 |
21 | 22 |
ParameterVar
23 |

A reference to the variable. For example: IsByRef(MyParameter).

24 | 25 |
26 | 27 |

Return Value

28 |

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 | 31 |

ByRef parameters

32 |

Examples

33 |
34 |

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 |
42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /docs/commands/Asc.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Asc() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Asc()

15 | 16 |

Returns the numeric value of the first byte or UTF-16 code unit in the specified string.

17 | 18 |
Number := Asc(String)
19 |

Parameters

20 |
21 | 22 |
String
23 |

The string whose numeric value is retrieved.

24 | 25 |
26 | 27 |

Return Value

28 |

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 |

Remarks

31 |

This function is equivalent to Transform, OutputVar, Asc.

32 |

To allow for Unicode supplementary characters, use Ord(String) instead.

33 | 34 | 35 |

Transform, Ord(), Chr()

36 |

Examples

37 |
38 |

Both message boxes below show 116, because only the first character is considered.

39 |
MsgBox, % Asc("t") 
40 | MsgBox, % Asc("test")
41 |
42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /docs/commands/_WinActivateForce.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #WinActivateForce - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

#WinActivateForce

14 | 15 |

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 |

Remarks

22 |

Like other directives, #WinActivateForce cannot be executed conditionally.

23 | 24 | 25 |

WinActivate, WinActivateBottom, GroupActivate

26 |

Examples

27 |
28 |

Enables the forceful method of activating a window.

29 |
#WinActivateForce
30 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/commands/Trim.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Trim() / LTrim() / RTrim() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Trim() / LTrim() / RTrim() [AHK_L 31+]

14 | 15 |

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 |

Parameters

23 |
24 | 25 |
String
26 |

Any string value or variable. Numbers are not supported.

27 | 28 |
OmitChars
29 |

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.

30 | 31 |
32 | 33 |

Examples

34 |
35 |

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 |
42 | 43 |
44 |

Trims all zeros from the left side of a string.

45 |
MsgBox % LTrim("00000123", "0")
46 |
47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/commands/FileCreateDir.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FileCreateDir - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

FileCreateDir

15 | 16 |

Creates a folder.

17 | 18 |
FileCreateDir, DirName
19 |

Parameters

20 |
21 | 22 |
DirName
23 |

Name of the directory to create, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.

24 | 25 |
26 |

Error Handling

27 |

[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 |

Remarks

31 | This command will also create all parent directories given in DirName if they do not already exist. 32 | 33 |

FileRemoveDir

34 |

Examples

35 |
36 |

Creates a new directory, including its parent directories if necessary.

37 |
FileCreateDir, C:\Test1\My Images\Folder2
38 |
39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /docs/commands/StrLen.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | StrLen() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

StrLen()

14 |

Retrieves the count of how many characters are in a string.

15 |
Length := StrLen(String)
16 | 17 |

Parameters

18 |
19 |
String
20 |
The string whose contents will be measured.
21 |
22 | 23 |

Return Value

24 |

This function returns the length of the string.

25 | 26 |

Remarks

27 |

If String is a variable to which ClipboardAll was previously assigned, StrLen() will retrieve its total size.

28 | 29 | 30 |

StringLen, InStr(), SubStr(), Trim(), StringLower, StringUpper, StrPut(), StrGet(), StrReplace(), StrSplit()

31 | 32 |

Examples

33 |
34 |

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: 43
37 |
38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/commands/_HotkeyInterval.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #HotkeyInterval - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

#HotkeyInterval

15 | 16 |

Along with #MaxHotkeysPerInterval, specifies the rate of hotkey activations beyond which a warning dialog will be displayed.

17 | 18 |
#HotkeyInterval Milliseconds
19 |

Parameters

20 |
21 | 22 |
Milliseconds
23 |

The length of the interval in milliseconds.

24 | 25 |
26 |

Remarks

27 |

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 | 31 |

#MaxHotkeysPerInterval

32 |

Examples

33 |
34 |

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 200
37 |
38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/commands/ComObjValue.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ComObjValue() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

ComObjValue() [v1.0.91+]

14 | 15 |

Retrieves the value or pointer stored in a COM wrapper object.

16 | 17 |
Value := ComObjValue(ComObject)
18 | 19 |

Parameters

20 |
21 | 22 |
ComObject
23 |

A wrapper object containing a COM object or typed value.

24 | 25 |
26 | 27 |

Return Value

28 |

This function returns a 64-bit signed integer.

29 | 30 |

General Remarks

31 |

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.

33 | 34 | 35 |

ComObjType(), ComObjCreate(), ComObjGet(), ComObjActive()

36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/commands/OutputDebug.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OutputDebug - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

OutputDebug

14 | 15 |

Sends a string to the debugger (if any) for display.

16 | 17 |
OutputDebug, Text
18 |

Parameters

19 |
20 | 21 |
Text
22 |

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.

23 | 24 |
25 | 26 |

Remarks

27 |

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 | 31 |

FileAppend, continuation sections

32 |

Examples

33 |
34 |

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 |
37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/commands/Ord.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ord() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Ord() [v1.1.21+]

14 | 15 |

Returns the ordinal value (numeric character code) of the first character in the specified string.

16 | 17 |
Number := Ord(String)
18 |

Parameters

19 |
20 | 21 |
String
22 |

The string whose ordinal value is retrieved.

23 | 24 |
25 | 26 |

Return Value

27 |

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 |

Remarks

30 |

Apart from the Unicode supplementary character detection, this function is identical to Asc().

31 | 32 | 33 |

Asc(), Chr()

34 |

Examples

35 |
36 |

Both message boxes below show 116, because only the first character is considered.

37 |
MsgBox, % Ord("t") 
38 | MsgBox, % Ord("test")
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /docs/scripts/EasyWindowDrag.ahk: -------------------------------------------------------------------------------- 1 | ; Easy Window Dragging (requires XP/2k/NT) 2 | ; https://www.autohotkey.com 3 | ; Normally, a window can only be dragged by clicking on its title bar. 4 | ; This script extends that so that any point inside a window can be dragged. 5 | ; To activate this mode, hold down CapsLock or the middle mouse button while 6 | ; clicking, then drag the window to a new position. 7 | 8 | ; Note: You can optionally release CapsLock or the middle mouse button after 9 | ; pressing down the mouse button rather than holding it down the whole time. 10 | ; This script requires v1.0.25+. 11 | 12 | ~MButton & LButton:: 13 | CapsLock & LButton:: 14 | CoordMode, Mouse ; Switch to screen/absolute coordinates. 15 | MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin 16 | WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin% 17 | WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin% 18 | if EWD_WinState = 0 ; Only if the window isn't maximized 19 | SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it. 20 | return 21 | 22 | EWD_WatchMouse: 23 | GetKeyState, EWD_LButtonState, LButton, P 24 | if EWD_LButtonState = U ; Button has been released, so drag is complete. 25 | { 26 | SetTimer, EWD_WatchMouse, Off 27 | return 28 | } 29 | GetKeyState, EWD_EscapeState, Escape, P 30 | if EWD_EscapeState = D ; Escape has been pressed, so drag is cancelled. 31 | { 32 | SetTimer, EWD_WatchMouse, Off 33 | WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY% 34 | return 35 | } 36 | ; Otherwise, reposition the window to match the change in mouse coordinates 37 | ; caused by the user having dragged the mouse: 38 | CoordMode, Mouse 39 | MouseGetPos, EWD_MouseX, EWD_MouseY 40 | WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin% 41 | SetWinDelay, -1 ; Makes the below move faster/smoother. 42 | WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY 43 | EWD_MouseStartX := EWD_MouseX ; Update for the next timer-call to this subroutine. 44 | EWD_MouseStartY := EWD_MouseY 45 | return 46 | -------------------------------------------------------------------------------- /docs/scripts/WindowShading.ahk: -------------------------------------------------------------------------------- 1 | ; Window Shading (roll up a window to its title bar) -- by Rajat 2 | ; https://www.autohotkey.com 3 | ; This script reduces a window to its title bar and then back to its 4 | ; original size by pressing a single hotkey. Any number of windows 5 | ; can be reduced in this fashion (the script remembers each). If the 6 | ; script exits for any reason, all "rolled up" windows will be 7 | ; automatically restored to their original heights. 8 | 9 | ; Set the height of a rolled up window here. The operating system 10 | ; probably won't allow the title bar to be hidden regardless of 11 | ; how low this number is: 12 | ws_MinHeight = 25 13 | 14 | ; This line will unroll any rolled up windows if the script exits 15 | ; for any reason: 16 | OnExit, ExitSub 17 | return ; End of auto-execute section 18 | 19 | #z:: ; Change this line to pick a different hotkey. 20 | ; Below this point, no changes should be made unless you want to 21 | ; alter the script's basic functionality. 22 | ; Uncomment this next line if this subroutine is to be converted 23 | ; into a custom menu item rather than a hotkey. The delay allows 24 | ; the active window that was deactivated by the displayed menu to 25 | ; become active again: 26 | ;Sleep, 200 27 | WinGet, ws_ID, ID, A 28 | Loop, Parse, ws_IDList, | 29 | { 30 | IfEqual, A_LoopField, %ws_ID% 31 | { 32 | ; Match found, so this window should be restored (unrolled): 33 | StringTrimRight, ws_Height, ws_Window%ws_ID%, 0 34 | WinMove, ahk_id %ws_ID%,,,,, %ws_Height% 35 | StringReplace, ws_IDList, ws_IDList, |%ws_ID% 36 | return 37 | } 38 | } 39 | WinGetPos,,,, ws_Height, A 40 | ws_Window%ws_ID% = %ws_Height% 41 | WinMove, ahk_id %ws_ID%,,,,, %ws_MinHeight% 42 | ws_IDList = %ws_IDList%|%ws_ID% 43 | return 44 | 45 | ExitSub: 46 | Loop, Parse, ws_IDList, | 47 | { 48 | if A_LoopField = ; First field in list is normally blank. 49 | continue ; So skip it. 50 | StringTrimRight, ws_Height, ws_Window%A_LoopField%, 0 51 | WinMove, ahk_id %A_LoopField%,,,,, %ws_Height% 52 | } 53 | ExitApp ; Must do this for the OnExit subroutine to actually Exit the script. 54 | -------------------------------------------------------------------------------- /docs/commands/Func.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Func() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Func() [v1.1.00+]

15 | 16 |

Retrieves a reference to a function.

17 | 18 |
FunctionReference := Func(FunctionName)
19 |

Parameters

20 |
21 | 22 |
FunctionName
23 |

The name of the function whose reference is retrieved. FunctionName must exist explicitly in the script.

24 | 25 |
26 | 27 |

Return Value

28 |

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 |

Remarks

31 |

This function can be used to call the function or retrieve information such as the minimum and maximum number of parameters.

32 | 33 | 34 |

Function References, Func Object

35 |

Examples

36 |
37 |

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 |
41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/commands/Goto.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Goto - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Goto

14 | 15 |

Jumps to the specified label and continues execution.

16 | 17 |
Goto, Label
18 |

Parameters

19 |
20 | 21 |
Label
22 |

The name of the label to which to jump.

23 | 24 |
25 | 26 |

Remarks

27 |

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 | 32 |

Gosub, Return, IsLabel(), Else, Blocks, Break, Continue, A_ThisLabel

33 |

Examples

34 |
35 |

Jumps to the label named "MyLabel" and continues execution.

36 |
Goto, MyLabel
37 | ; ...
38 | MyLabel:
39 | Sleep, 100
40 | ; ...
41 |
42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /docs/commands/SoundBeep.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SoundBeep - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

SoundBeep

14 | 15 |

Emits a tone from the PC speaker.

16 | 17 |
SoundBeep , Frequency, Duration
18 |

Parameters

19 |
20 | 21 |
Frequency
22 |

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.

23 | 24 |
Duration
25 |

The duration of the sound, in milliseconds (can be an expression). If omitted, the duration will be 150.

26 | 27 |
28 | 29 |

Remarks

30 |

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 | 34 |

SoundPlay

35 |

Examples

36 |
37 |

Plays the default pitch and duration.

38 |
SoundBeep
39 |
40 | 41 |
42 |

Plays a higher pitch for half a second.

43 |
SoundBeep, 750, 500
44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /docs/commands/_CommentFlag.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #CommentFlag - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

#CommentFlag

15 | 16 |

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 |

Parameters

21 |
22 | 23 |
NewString
24 |

One or more characters that should be used as the new comment flag. Up to 15 characters may be specified.

25 | 26 |
27 |

Remarks

28 |

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 | 35 |

#EscapeChar

36 |

Examples

37 |
38 |

Changes to C++ comment style.

39 |
#CommentFlag //
40 |
41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/commands/_NoTrayIcon.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #NoTrayIcon - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

#NoTrayIcon

14 | 15 |

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.

20 |

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.

21 |

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 | 24 |

Tray Icon, Menu, ExitApp

25 |

Examples

26 |
27 |

Causes the script to launch without a tray icon.

28 |
#NoTrayIcon
29 |
30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /docs/commands/IfMsgBox.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IfMsgBox - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

IfMsgBox

15 | 16 |

Checks which button was pushed by the user during the most recent MsgBox command.

17 | 18 |
IfMsgBox, ButtonName
19 |

Parameters

20 |
21 | 22 |
ButtonName
23 |

One of the following strings to represent which button the user pressed in the most recent MsgBox command:

24 | 36 |
37 | 38 |
39 | 40 | 41 |

MsgBox

42 |

Examples

43 |
44 |

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 |
53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /docs/commands/IniDelete.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IniDelete - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

IniDelete

14 | 15 |

Deletes a value from a standard format .ini file.

16 | 17 |
IniDelete, Filename, Section , Key
18 |

Parameters

19 |
20 | 21 |
Filename
22 |

The name of the .ini file, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.

23 | 24 |
Section
25 |

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).

26 | 27 |
Key
28 |

The key name in the .ini file. If omitted, the entire Section will be deleted.

29 | 30 |
31 |

Error Handling

32 |

[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 |

Remarks

35 |

A standard ini file looks like:

36 |
[SectionName]
37 | Key=Value
38 | 39 |

IniRead, IniWrite, RegDelete

40 |

Examples

41 |
42 |

Deletes a key and its value located in section2 from a standard format .ini file.

43 |
IniDelete, C:\Temp\myfile.ini, section2, key
44 |
45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /docs/commands/MenuGetHandle.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | MenuGetHandle() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

MenuGetHandle() [v1.1.23+]

15 | 16 |

Retrieves the Win32 menu handle of a menu.

17 |
Handle := MenuGetHandle(MenuName)
18 | 19 |

Parameters

20 |
21 | 22 |
MenuName
23 |

The name of an existing menu. Menu names are not case sensitive.

24 | 25 |
26 | 27 |

Remarks

28 |

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 | 31 |

Menu, MenuGetName()

32 | 33 |

Examples

34 |
35 |

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 |
52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /docs/commands/IfExist.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IfExist / IfNotExist - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

IfExist / IfNotExist

15 | 16 |

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 |

Parameters

24 |
25 | 26 |
FilePattern
27 |

The path, filename, or file pattern to check. FilePattern is assumed to be in %A_WorkingDir% if an absolute path isn't specified.

28 | 29 |
30 | 31 | 32 |

FileExist(), Blocks, Else, File-loops

33 |

Examples

34 |
35 |

Shows a message box if the D drive does exist.

36 |
IfExist, D:\
37 |     MsgBox, The drive exists.
38 |
39 | 40 |
41 |

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 |
45 | 46 |
47 |

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 |
51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /docs/commands/Chr.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Chr() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Chr()

14 | 15 |

Returns the string (usually a single character) corresponding to the character code indicated by the specified number.

16 | 17 |
String := Chr(Number)
18 |

Parameters

19 |
20 | 21 |
Number
22 |

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.

23 | 24 |
25 | 26 |

Return Value

27 |

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 |

Remarks

30 |

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 | 35 |

Transform, Ord(), Asc()

36 | 37 |

Examples

38 |
39 |

Reports the string corresponding to the character code 116.

40 |
MsgBox % Chr(116) ; Reports "t".
41 |
42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /docs/commands/ExitApp.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ExitApp - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

ExitApp

14 | 15 |

Terminates the script.

16 | 17 |
ExitApp , ExitCode
18 |

Parameters

19 |
20 | 21 |
ExitCode
22 |

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.

23 | 24 |
25 | 26 |

Remarks

27 |

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 | 32 |

Exit, OnExit(), OnExit, #Persistent

33 | 34 |

Examples

35 |
36 |

Press a hotkey to terminate the script.

37 |
#x::ExitApp  ; Win+X
38 |
39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /docs/commands/_KeyHistory.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #KeyHistory - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

#KeyHistory

15 | 16 |

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 |

Parameters

20 |
21 | 22 |
MaxEvents
23 |

The maximum number of keyboard and mouse events displayed by the KeyHistory window (default 40, limit 500). Specify 0 to disable key history entirely.

24 | 25 |
26 |

Remarks

27 |

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.

29 |

Like other directives, #KeyHistory cannot be executed conditionally.

30 | 31 |

KeyHistory, #NoTrayIcon

32 |

Examples

33 |
34 |

Causes KeyHistory to display the last 100 instead 40 keyboard and mouse events.

35 |
#KeyHistory 100
36 |
37 | 38 |
39 |

Disables key history entirely.

40 |
#KeyHistory 0
41 |
42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /docs/commands/GetKey.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GetKeyName() / GetKeyVK() / GetKeySC() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

GetKeyName() / GetKeyVK() / GetKeySC() [v1.1.01+]

15 | 16 |

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 |

Parameters

24 |
25 | 26 |
Key
27 |

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).

28 | 29 |
30 | 31 |

Return Value

32 |

These functions return a name, virtual key code or scan code of Key.

33 | 34 | 35 |

GetKeyState(), Key List, Format()

36 |

Examples

37 |
38 |

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 |
47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/commands/StringLen.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | StringLen - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

StringLen

15 |

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 |

Parameters

20 |
21 | 22 |
OutputVar
23 |
The name of the variable in which to store the length.
24 | 25 |
InputVar
26 |
The name of the variable whose contents will be measured. Do not enclose the name in percent signs unless you want the contents of the variable to be used as the name.
27 | 28 |
29 | 30 |

Remarks

31 |

If InputVar is a variable to which ClipboardAll was previously assigned, StringLen will retrieve its total size.

32 | 33 | 34 |

StrLen(), IfInString, StringGetPos, StringMid, StringTrimLeft, StringTrimRight, StringLeft, StringRight, StringLower, StringUpper, StringReplace

35 | 36 |

Examples

37 |
38 |

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 |
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /docs/commands/WinGetClass.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinGetClass - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

WinGetClass

14 | 15 |

Retrieves the specified window's class name.

16 | 17 |
WinGetClass, OutputVar , WinTitle, WinText, ExcludeTitle, ExcludeText
18 |

Parameters

19 |
20 | 21 |
OutputVar
22 |

The name of the variable in which to store the retrieved class name.

23 | 24 |
WinTitle
25 |

A window title or other criteria identifying the target window. See WinTitle.

26 | 27 |
WinText
28 |

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.

29 | 30 |
ExcludeTitle
31 |

Windows whose titles include this value will not be considered.

32 | 33 |
ExcludeText
34 |

Windows whose text include this value will not be considered.

35 | 36 |
37 | 38 |

Remarks

39 |

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 | 44 |

WinGet, WinGetTitle

45 |

Examples

46 |
47 |

Retrieves and reports the class name of the active window.

48 |
WinGetClass, class, A
49 | MsgBox, The active window's class is "%class%".
50 |
51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /docs/commands/IsFunc.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IsFunc() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

IsFunc() [v1.0.48+]

15 | 16 |

Returns a non-zero number if the specified function exists in the script.

17 | 18 |
MinParamsPlus1 := IsFunc(FunctionName)
19 |

Parameters

20 |
21 | 22 |
FunctionName
23 |

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.

24 | 25 |
26 | 27 |

Return Value

28 |

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 | 31 |

Dynamically Calling a Function, Function References, Func Object, Func(), A_ThisFunc

32 |

Examples

33 |
34 |

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 |
41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/commands/_MaxHotkeysPerInterval.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #MaxHotkeysPerInterval - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

#MaxHotkeysPerInterval

15 | 16 |

Along with #HotkeyInterval, specifies the rate of hotkey activations beyond which a warning dialog will be displayed.

17 | 18 |
#MaxHotkeysPerInterval Value
19 |

Parameters

20 |
21 | 22 |
Value
23 |

The maximum number of hotkeys that can be pressed in the interval specified by #HotkeyInterval without triggering a warning dialog.

24 | 25 |
26 |

Remarks

27 |

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.

29 |

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 | 32 |

#HotkeyInterval

33 |

Examples

34 |
35 |

Allows to press a maximum of 200 instead of 70 hotkeys per interval.

36 |
#MaxHotkeysPerInterval 200
37 |
38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/scripts/Numpad000.ahk: -------------------------------------------------------------------------------- 1 | ; Numpad 000 Key 2 | ; https://www.autohotkey.com 3 | ; This example script makes the special 000 key that appears on certain 4 | ; keypads into an equals key. You can change the action by replacing the 5 | ; “Send, =” line with line(s) of your choice. 6 | 7 | #MaxThreadsPerHotkey 5 ; Allow multiple threads for this hotkey. 8 | $Numpad0:: 9 | #MaxThreadsPerHotkey 1 10 | ; Above: Use the $ to force the hook to be used, which prevents an 11 | ; infinite loop since this subroutine itself sends Numpad0, which 12 | ; would otherwise result in a recursive call to itself. 13 | SetBatchLines, 100 ; Make it run a little faster in this case. 14 | DelayBetweenKeys = 30 ; Adjust this value if it doesn't work. 15 | if A_PriorHotkey = %A_ThisHotkey% 16 | { 17 | if A_TimeSincePriorHotkey < %DelayBetweenKeys% 18 | { 19 | if Numpad0Count = 20 | Numpad0Count = 2 ; i.e. This one plus the prior one. 21 | else if Numpad0Count = 0 22 | Numpad0Count = 2 23 | else 24 | { 25 | ; Since we're here, Numpad0Count must be 2 as set by 26 | ; prior calls, which means this is the third time the 27 | ; the key has been pressed. Thus, the hotkey sequence 28 | ; should fire: 29 | Numpad0Count = 0 30 | Send, = ; ******* This is the action for the 000 key 31 | } 32 | ; In all the above cases, we return without further action: 33 | CalledReentrantly = y 34 | return 35 | } 36 | } 37 | ; Otherwise, this Numpad0 event is either the first in the series 38 | ; or it happened too long after the first one (e.g. perhaps the 39 | ; user is holding down the Numpad0 key to auto-repeat it, which 40 | ; we want to allow). Therefore, after a short delay -- during 41 | ; which another Numpad0 hotkey event may re-entrantly call this 42 | ; subroutine -- we'll send the key on through if no reentrant 43 | ; calls occurred: 44 | Numpad0Count = 0 45 | CalledReentrantly = n 46 | ; During this sleep, this subroutine may be reentrantly called 47 | ; (i.e. a simultaneous "thread" which runs in parallel to the 48 | ; call we're in now): 49 | Sleep, %DelayBetweenKeys% 50 | if CalledReentrantly = y ; Another "thread" changed the value. 51 | { 52 | ; Since it was called reentrantly, this key event was the first in 53 | ; the sequence so should be suppressed (hidden from the system): 54 | CalledReentrantly = n 55 | return 56 | } 57 | ; Otherwise it's not part of the sequence so we send it through normally. 58 | ; In other words, the *real* Numpad0 key has been pressed, so we want it 59 | ; to have its normal effect: 60 | Send, {Numpad0} 61 | return 62 | -------------------------------------------------------------------------------- /docs/misc/Macros.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Creating a Keyboard Macro or Mouse Macro | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Creating a Keyboard Macro or Mouse Macro

15 | 16 |

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 |

-- Home --

30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/commands/IsLabel.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IsLabel() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

IsLabel()

14 | 15 |

Returns a non-zero number if the specified label exists in the script.

16 | 17 |
TrueOrFalse := IsLabel(LabelName)
18 |

Parameters

19 |
20 | 21 |
LabelName
22 |

The name of a subroutine, hotkey, or hotstring (do not include the trailing colon(s) in LabelName).

23 | 24 |
25 | 26 |

Return Value

27 |

This function returns a non-zero number if LabelName exists in the script.

28 | 29 |

Remarks

30 |

This function is useful to avoid runtime errors when specifying a dynamic label in commands such as Gosub, Hotkey, Menu, and Gui.

31 | 32 |

Labels

33 |

Examples

34 |
35 |

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 |
44 | 45 |
46 |

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 |
54 | 55 |
56 |

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 |
64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /docs/commands/Until.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Until - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Until [AHK_L 59+]

14 | 15 |

Applies a condition to the continuation of a Loop or For-loop.

16 | 17 |
18 | Loop {
19 |     ...
20 | } Until Expression
21 | 
22 |

Parameters

23 |
24 | 25 |
Expression
26 |

Any valid expression.

27 | 28 |
29 | 30 |

Remarks

31 |

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 > y
42 |

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 | 51 |

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 | FileDelete - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

FileDelete

14 | 15 |

Deletes one or more files.

16 | 17 |
FileDelete, FilePattern
18 |

Parameters

19 |
20 | 21 |
FilePattern
22 |

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 remove an entire folder, along with all its sub-folders and files, use FileRemoveDir.

24 | 25 |
26 | 27 |

Error Handling

28 |

[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.

30 |

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 |

Remarks

33 |

To delete a read-only file, first remove the read-only attribute. For example: FileSetAttrib, -R, C:\My File.txt.

34 | 35 |

FileRecycle, FileRemoveDir, FileCopy, FileMove

36 |

Examples

37 |
38 |

Deletes all .tmp files in a directory.

39 |
FileDelete, C:\temp files\*.tmp
40 |
41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/misc/Override.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Overriding or Disabling Hotkeys | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Overriding or Disabling Hotkeys

14 | 15 |

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 | return
23 |

In the next example, the Win+R hotkey, which is used to open the RUN window, is completely disabled:

24 |
#r::return
25 |

Similarly, to disable both Win, use this:

26 |
LWin::return
27 | RWin::return
28 |

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 | WinShow - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

WinShow

14 | 15 |

Unhides the specified window.

16 | 17 |
WinShow , WinTitle, WinText, ExcludeTitle, ExcludeText
18 |

Parameters

19 |
20 | 21 |
WinTitle
22 |

A window title or other criteria identifying the target window. See WinTitle.

23 | 24 |
WinText
25 |

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.

26 | 27 |
ExcludeTitle
28 |

Windows whose titles include this value will not be considered.

29 | 30 |
ExcludeText
31 |

Windows whose text include this value will not be considered.

32 | 33 |
34 | 35 |

Remarks

36 |

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 | 39 |

WinHide, SetTitleMatchMode, DetectHiddenWindows, Last Found Window

40 |

Examples

41 |
42 |

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 |
50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /docs/commands/_EscapeChar.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #EscapeChar - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

#EscapeChar

15 | 16 |

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 |

Parameters

21 |
22 | 23 |
NewChar
24 |

Specify a single character.

25 | 26 |
27 |

Remarks

28 |

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).

31 |

Like other directives, #EscapeChar cannot be executed conditionally.

32 | 33 | 34 |

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 |

Examples

39 |
40 |

Changes the default escape character (`) to backslash.

41 |
#EscapeChar \
42 |
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /docs/commands/FileRecycle.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FileRecycle - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

FileRecycle

14 | 15 |

Sends a file or directory to the recycle bin if possible, or permanently deletes it.

16 | 17 |
FileRecycle, FilePattern
18 |

Parameters

19 |
20 | 21 |
FilePattern
22 |

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.

24 | 25 |
26 | 27 |

Error Handling

28 |

[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 |

Remarks

31 |

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 | 37 | 38 |

FileRecycleEmpty, FileDelete, FileCopy, FileMove

39 |

Examples

40 |
41 |

Sends all .tmp files in a directory to the recycle bin if possible.

42 |
FileRecycle, C:\temp files\*.tmp
43 |
44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /docs/commands/_NoEnv.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #NoEnv - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

#NoEnv [v1.0.43.08+]

15 | 16 |

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:

19 |
#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).

22 |

Specifying #NoEnv is recommended for all new scripts because:

23 |
    24 |
  1. It significantly improves performance whenever empty variables are used in an expression or command. It also improves DllCall's performance when unquoted parameter types are used (e.g. int vs. "int").
  2. 25 |
  3. It prevents script bugs caused by environment variables whose names unexpectedly match variables used by the script.
  4. 26 |
  5. AutoHotkey v2 will make this behavior the default.
  6. 27 |
28 |

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 | 32 |

EnvGet, ComSpec, ProgramFiles, A_WinDir

33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /docs/commands/EnvGet.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EnvGet - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

EnvGet [v1.0.43.08+]

14 | 15 |

Retrieves an environment variable.

16 | 17 |
EnvGet, OutputVar, EnvVarName
18 |

Parameters

19 |
20 | 21 |
OutputVar
22 |

The name of the variable in which to store the string.

23 | 24 |
EnvVarName
25 |

The name of the environment variable to retrieve. For example: EnvGet, OutputVar, Path.

26 | 27 |
28 |

Remarks

29 |

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 | 32 |

EnvSet, #NoEnv, environment variables, EnvUpdate, SetEnv, Run, RunWait

33 |

Examples

34 |
35 |

Retrieves an environment variable and stores its value in OutputVar.

36 |
EnvGet, OutputVar, LogonServer
37 |
38 | 39 |
40 |

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 |
44 | 45 |
46 |

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 |
50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /docs/commands/WinRestore.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinRestore - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

WinRestore

14 | 15 |

Unminimizes or unmaximizes the specified window if it is minimized or maximized.

16 | 17 |
WinRestore , WinTitle, WinText, ExcludeTitle, ExcludeText
18 |

Parameters

19 |
20 | 21 |
WinTitle
22 |

A window title or other criteria identifying the target window. See WinTitle.

23 | 24 |
WinText
25 |

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.

26 | 27 |
ExcludeTitle
28 |

Windows whose titles include this value will not be considered.

29 | 30 |
ExcludeText
31 |

Windows whose text include this value will not be considered.

32 | 33 |
34 | 35 |

Remarks

36 |

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_RESTORE
38 |

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 | 41 |

WinMinimize, WinMaximize

42 |

Examples

43 |
44 |

Unminimizes or unmaximizes Notepad if it is minimized or maximized.

45 |
WinRestore, Untitled - Notepad
46 |
47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/commands/EnvMult.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EnvMult - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

EnvMult

15 | 16 |

Sets a variable to itself times the given value. Synonymous with: Var *= Value.

17 |

Deprecated: This command is not recommended for use in new scripts. Use Var := Var * Value or Var *= Value instead.

18 | 19 |
EnvMult, Var, Value
20 |

Parameters

21 |
22 | 23 |
Var
24 |

The name of the variable upon which to operate.

25 | 26 |
Value
27 |

Any integer, floating point number, or expression.

28 | 29 |
30 | 31 |

Remarks

32 |

This command is equivalent to the shorthand style: Var *= Value.

33 |

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).

34 |

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 | 36 |

EnvAdd, EnvSub, EnvDiv, SetFormat, Expressions, If var is [not] type, SetEnv, bitwise operations (Transform)

37 |

Examples

38 |
39 |

Sets MyCount to itself times 2.

40 |
EnvMult, MyCount, 2
41 |
42 | 43 |
44 |

Equivalent to above.

45 |
MyCount *= 2
46 |
47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/commands/Break.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Break - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Break

14 |

Exits (terminates) any type of loop statement.

15 |
Break , LoopLabel
16 | 17 |

Parameters

18 |
19 |
LoopLabel [AHK_L 59+]
20 |
LoopLabel identifies which loop this statement should apply to; either by label name or numeric nesting level. If omitted or 1, this statement applies to the innermost loop in which it is enclosed. LoopLabel must be a constant value - variables and expressions are not supported. If a label is specified, it must point directly at a loop statement.
21 |
22 | 23 |

Remarks

24 |

The use of Break and Continue are encouraged over Goto since they usually make scripts more readable and maintainable.

25 | 26 |

Continue, Loop, While-loop, For-loop, Blocks, Labels

27 | 28 |

Examples

29 |
30 |

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 |
41 | 42 |
43 |

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 |
58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /docs/commands/WinGetTitle.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinGetTitle - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

WinGetTitle

14 | 15 |

Retrieves the title of the specified window.

16 | 17 |
WinGetTitle, OutputVar , WinTitle, WinText, ExcludeTitle, ExcludeText
18 |

Parameters

19 |
20 | 21 |
OutputVar
22 |

The name of the variable in which to store the retrieved title.

23 | 24 |
WinTitle
25 |

A window title or other criteria identifying the target window. See WinTitle.

26 | 27 |
WinText
28 |

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.

29 | 30 |
ExcludeTitle
31 |

Windows whose titles include this value will not be considered.

32 | 33 |
ExcludeText
34 |

Windows whose text include this value will not be considered.

35 | 36 |
37 | 38 |

Remarks

39 |

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 | 43 |

WinGetActiveStats, WinGetActiveTitle, WinGetClass, WinGet, WinGetText, ControlGetText, WinGetPos

44 |

Examples

45 |
46 |

Retrieves and reports the title of the active window.

47 |
WinGetTitle, Title, A
48 | MsgBox, The active window is "%Title%".
49 |
50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /docs/commands/FileRemoveDir.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FileRemoveDir - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

FileRemoveDir

15 | 16 |

Deletes a folder.

17 | 18 |
FileRemoveDir, DirName , Recurse
19 |

Parameters

20 |
21 | 22 |
DirName
23 |

Name of the directory to delete, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.

24 | 25 |
Recurse
26 |
27 |

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 |
32 | 33 |
34 |

Error Handling

35 |

[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 | 39 |

FileCreateDir, FileDelete

40 |

Examples

41 |
42 |

Removes the directory, but only if it is empty.

43 |
FileRemoveDir, C:\Download Temp
44 |
45 | 46 |
47 |

Removes the directory including its files and subdirectories.

48 |
FileRemoveDir, C:\Download Temp, 1
49 |
50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /docs/objects/Enumerator.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Enumerator Object - Definition & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Enumerator Object [AHK_L 49+]

14 | 15 |

Allows items in a collection to be enumerated.

16 | 17 |

Table of Contents

18 | 25 | 26 |

Methods

27 |
28 |

Next

29 |

Retrieves the next item or items in an enumeration.

30 |
Boolean := Enum.Next(OutputVar1 , OutputVar2, ...)
31 |
32 |
OutputVar1, OutputVar2
33 |
Receives an implementation-specific value.
34 |
...
35 |
Additional parameters, if supported.
36 |
37 |

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 | 43 |

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 |
61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /docs/scripts/ContextSensitiveHelp.ahk: -------------------------------------------------------------------------------- 1 | ; Context Sensitive Help in Any Editor -- by Rajat 2 | ; https://www.autohotkey.com 3 | ; This script makes Ctrl+2 (or another hotkey of your choice) show the help file 4 | ; page for the selected AutoHotkey command or keyword. If nothing is selected, 5 | ; the command name will be extracted from the beginning of the current line. 6 | 7 | ; The hotkey below uses the clipboard to provide compatibility with the maximum 8 | ; number of editors (since ControlGet doesn't work with most advanced editors). 9 | ; It restores the original clipboard contents afterward, but as plain text, 10 | ; which seems better than nothing. 11 | 12 | $^2:: 13 | ; The following values are in effect only for the duration of this hotkey thread. 14 | ; Therefore, there is no need to change them back to their original values 15 | ; because that is done automatically when the thread ends: 16 | SetWinDelay 10 17 | SetKeyDelay 0 18 | AutoTrim, On 19 | 20 | if A_OSType = WIN32_WINDOWS ; Windows 9x 21 | Sleep, 500 ; Give time for the user to release the key. 22 | 23 | C_ClipboardPrev = %clipboard% 24 | clipboard = 25 | ; Use the highlighted word if there is one (since sometimes the user might 26 | ; intentionally highlight something that isn't a command): 27 | Send, ^c 28 | ClipWait, 0.1 29 | if ErrorLevel <> 0 30 | { 31 | ; Get the entire line because editors treat cursor navigation keys differently: 32 | Send, {home}+{end}^c 33 | ClipWait, 0.2 34 | if ErrorLevel <> 0 ; Rare, so no error is reported. 35 | { 36 | clipboard = %C_ClipboardPrev% 37 | return 38 | } 39 | } 40 | C_Cmd = %clipboard% ; This will trim leading and trailing tabs & spaces. 41 | clipboard = %C_ClipboardPrev% ; Restore the original clipboard for the user. 42 | Loop, parse, C_Cmd, %A_Space%`, ; The first space or comma is the end of the command. 43 | { 44 | C_Cmd = %A_LoopField% 45 | break ; i.e. we only need one interation. 46 | } 47 | IfWinNotExist, AutoHotkey Help 48 | { 49 | ; Determine AutoHotkey's location: 50 | RegRead, ahk_dir, HKEY_LOCAL_MACHINE, SOFTWARE\AutoHotkey, InstallDir 51 | if ErrorLevel ; Not found, so look for it in some other common locations. 52 | { 53 | if A_AhkPath 54 | SplitPath, A_AhkPath,, ahk_dir 55 | else IfExist ..\..\AutoHotkey.chm 56 | ahk_dir = ..\.. 57 | else IfExist %A_ProgramFiles%\AutoHotkey\AutoHotkey.chm 58 | ahk_dir = %A_ProgramFiles%\AutoHotkey 59 | else 60 | { 61 | MsgBox Could not find the AutoHotkey folder. 62 | return 63 | } 64 | } 65 | Run %ahk_dir%\AutoHotkey.chm 66 | WinWait AutoHotkey Help 67 | } 68 | ; The above has set the "last found" window which we use below: 69 | WinActivate 70 | WinWaitActive 71 | StringReplace, C_Cmd, C_Cmd, #, {#} 72 | Send, !n{home}+{end}%C_Cmd%{enter} 73 | return 74 | -------------------------------------------------------------------------------- /docs/commands/EnvSet.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EnvSet - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

EnvSet

14 | 15 |

Writes a value to a variable contained in the environment.

16 | 17 |
EnvSet, EnvVar, Value
18 |

Parameters

19 |
20 | 21 |
EnvVar
22 |
Name of the environment variable to use, e.g. "COMSPEC" 23 | or "PATH".
24 | 25 |
Value
26 |

Value to set the environment variable to.

27 | 28 |
29 |

Error Handling

30 |

[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 |

Remarks

33 |

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 | 37 |

EnvGet, #NoEnv, environment variables, EnvUpdate, SetEnv, Run, RunWait

38 |

Examples

39 |
40 |

Writes some text to the AutGUI variable contained in the environment.

41 |
EnvSet, AutGUI, Some text to put in the variable.
42 |
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /docs/commands/ComObjCreate.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ComObjCreate() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

ComObjCreate() [AHK_L 53+]

15 |

Creates a COM object.

16 |
ComObject := ComObjCreate(CLSID , IID)
17 | 18 |

Parameters

19 |
20 | 21 |
CLSID
22 |

CLSID or human-readable Prog ID of the COM object to create.

23 | 24 |
IID
25 |

[v1.0.96.00+]: The identifier of an interface the object supports.

26 | 27 |
28 | 29 |

Return Value

30 |

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 | 35 | ComObjGet(), ComObjActive(), ComObjConnect(), ComObjArray(), ComObjError(), ComObjQuery(), CreateObject (MSDN) 36 | 37 |

Examples

38 |

For a constantly growing list of examples, see the following forum topic: https://www.autohotkey.com/forum/topic61509.html.

39 |
40 |

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 |
46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /docs/commands/ObjAddRef.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ObjAddRef() / ObjRelease() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

ObjAddRef() / ObjRelease() [AHK_L 53+]

15 | 16 |

Increments or decrements an object's reference count.

17 | 18 |
ObjAddRef(Ptr)
19 | ObjRelease(Ptr)
20 | 21 |

Parameters

22 |
23 | 24 |
Ptr
25 |

An unmanaged object pointer or COM interface pointer.

26 | 27 |
28 | 29 |

Return Value

30 |

These functions return the new reference count. This value should be used only for debugging purposes.

31 | 32 | 33 |

Reference Counting

34 |

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 |

Examples

37 |
38 |

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 |
59 | 60 |

For another example, see ComObjConnect().

61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /docs/commands/WinHide.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinHide - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

WinHide

14 | 15 |

Hides the specified window.

16 | 17 |
WinHide , WinTitle, WinText, ExcludeTitle, ExcludeText
18 |

Parameters

19 |
20 | 21 |
WinTitle
22 |

A window title or other criteria identifying the target window. See WinTitle.

23 | 24 |
WinText
25 |

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.

26 | 27 |
ExcludeTitle
28 |

Windows whose titles include this value will not be considered.

29 | 30 |
ExcludeText
31 |

Windows whose text include this value will not be considered.

32 | 33 |
34 | 35 |

Remarks

36 |

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_TrayWnd
41 | 42 |

WinShow, SetTitleMatchMode, DetectHiddenWindows, Last Found Window, WinSet

43 |

Examples

44 |
45 |

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 |
53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /docs/commands/ComObjGet.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ComObjGet() - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

ComObjGet() [AHK_L 53+]

14 |

Returns a reference to an object provided by a COM component.

15 |
ComObject := ComObjGet(Name)
16 | 17 |

Parameters

18 |
19 | 20 |
Name
21 |

The display name of the object to be retrieved. See MkParseDisplayName (MSDN) for more information.

22 | 23 |
24 | 25 |

Remarks

26 |

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 | 29 | ComObjCreate(), ComObjActive(), ComObjConnect(), ComObjError(), ComObjQuery(), CoGetObject (MSDN) 30 | 31 |

Examples

32 |
33 |

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 |
53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /docs/commands/WinGetActiveStats.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinGetActiveStats - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

WinGetActiveStats

15 | 16 |

Combines the functions of WinGetActiveTitle and WinGetPos into one command.

17 | 18 |
WinGetActiveStats, Title, Width, Height, X, Y
19 |

Parameters

20 |
21 | 22 |
Title
23 |

The name of the variable in which to store the title of the active window.

24 | 25 |
Width, Height
26 |

The names of the variables in which to store the width and height of the active window.

27 | 28 |
X, Y
29 |

The names of the variables in which to store the X and Y coordinates of the active window's upper left corner.

30 | 31 |
32 | 33 |

Remarks

34 |

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, A
38 |

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 | 40 |

WinGetPos, WinGetActiveTitle, WinGetTitle, WinGetClass, WinGetText, ControlGetText

41 |

Examples

42 |
43 |

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 |
47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/search.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |

Searching...

12 | 13 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/commands/FileEncoding.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FileEncoding - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

FileEncoding [AHK_L 42+]

14 | 15 |

Sets the default encoding for FileRead, FileReadLine, Loop Read, FileAppend, and FileOpen().

16 | 17 |
FileEncoding , Encoding
18 | 19 |

Parameters

20 |
21 |
Encoding
22 |
23 |

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 |
30 |
31 | 32 |

Remarks

33 |

A_FileEncoding contains the current setting.

34 |

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 | 38 |

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 | #MaxMem - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

#MaxMem

15 | 16 |

Sets the maximum capacity of each variable to the specified number of megabytes.

17 | 18 |
#MaxMem Megabytes
19 |

Parameters

20 |
21 | 22 |
Megabytes
23 |

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.

24 | 25 |
26 |

Remarks

27 |

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 | 33 |

VarSetCapacity(), Variables, Sort, WinGetText, ControlGetText, #MaxThreads

34 |

Examples

35 |
36 |

Allows 256 MB instead of 64 MB per variable.

37 |
#MaxMem 256
38 |
39 | 40 |
41 |

Allows the maximum amount of MB per variable.

42 |
#MaxMem 4095
43 |
44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /docs/commands/_InstallMouseHook.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #InstallMouseHook - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

#InstallMouseHook

15 | 16 |

Forces the unconditional installation of the mouse hook.

17 | 18 |
#InstallMouseHook
19 |

Remarks

20 |

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 | 27 |

#InstallKeybdHook, #UseHook, Hotkey, #Persistent, KeyHistory, GetKeyState(), KeyWait

28 |

Examples

29 |
30 |

Installs the mouse hook unconditionally.

31 |
#InstallMouseHook
32 |
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /docs/commands/FileGetVersion.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FileGetVersion - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

FileGetVersion

14 | 15 |

Retrieves the version of a file.

16 | 17 |
FileGetVersion, OutputVar , Filename
18 |

Parameters

19 |
20 | 21 |
OutputVar
22 |

The name of the variable in which to store the version number/string.

23 | 24 |
Filename
25 |

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.

26 | 27 |
28 | 29 |

Error Handling

30 |

[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 |

Remarks

35 |

Most non-executable files (and even some EXEs) won't have a version, and thus OutputVar will be blank in these cases.

36 | 37 |

FileGetAttrib, FileSetAttrib, FileGetTime, FileSetTime, FileGetSize, File-loop

38 |

Examples

39 |
40 |

Retrieves the version of a file and stores it in Version.

41 |
FileGetVersion, Version, C:\My Application.exe
42 |
43 | 44 |
45 |

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.exe
47 |
48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /docs/commands/_InputLevel.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #InputLevel - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

#InputLevel [v1.1.06+]

14 |

Controls which artificial keyboard and mouse events are ignored by hotkeys and hotstrings.

15 |
#InputLevel Level
16 | 17 |

Parameters

18 |
19 | 20 |
Level
21 |

An integer between 0 and 100. If omitted, it defaults to 0.

22 | 23 |
24 | 25 |

General Remarks

26 |

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

29 |

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 | 34 |

SendLevel, Hotkeys, Hotstrings

35 | 36 |

Examples

37 |
38 |

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.

39 |
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 |
47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/commands/EnvDiv.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EnvDiv - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

EnvDiv

15 | 16 |

Sets a variable to itself divided by the given value. Synonymous with: Var /= Value.

17 |

Deprecated: This command is not recommended for use in new scripts. Use Var := Var / Value or Var /= Value instead.

18 | 19 |
EnvDiv, Var, Value
20 |

Parameters

21 |
22 | 23 |
Var
24 |

The name of the variable upon which to operate.

25 | 26 |
Value
27 |

Any integer, floating point number, or expression.

28 | 29 |
30 | 31 |

Remarks

32 |

This command is equivalent to the shorthand style: Var /= Value.

33 |

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).

35 |

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 | 37 |

EnvAdd, EnvSub, EnvMult, SetFormat, Expressions, If var is [not] type, SetEnv, bitwise operations (Transform)

38 |

Examples

39 |
40 |

Sets MyCount to itself divided by 2.

41 |
EnvDiv, MyCount, 2
42 |
43 | 44 |
45 |

Equivalent to above.

46 |
MyCount /= 2
47 |
48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /docs/commands/DetectHiddenText.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DetectHiddenText - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

DetectHiddenText

14 | 15 |

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 |

Parameters

19 |
20 | 21 |
OnOff
22 |

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 |
26 | 27 |
28 | 29 |

Remarks

30 |

"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 | 34 |

DetectHiddenWindows

35 |

Examples

36 |
37 |

Turns off the detection of hidden text.

38 |
DetectHiddenText, Off
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /docs/commands/_IfTimeout.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #IfTimeout - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

#IfTimeout [AHK_L 8+]

16 | 17 |

Sets the maximum time that may be spent evaluating a single #If expression.

18 | 19 |
#IfTimeout Timeout
20 |

Parameters

21 |
22 | 23 |
Timeout
24 |

The timeout value to apply globally, in milliseconds.

25 | 26 |
27 | 28 |

Remarks

29 |

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 | 38 |

#If

39 |

Examples

40 |
41 |

Sets the #If timeout to 10 ms instead of 1000 ms.

42 |
#IfTimeout 10
43 |
44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /docs/misc/Winamp.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Automating Winamp | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Automating Winamp

14 | 15 |

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 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 |
Key to sendEffect
cPause/UnPause
xPlay/Restart/UnPause
vStop
+vStop with Fadeout
^vStop after the current track
bNext Track
zPrevious Track
{left}Rewind 5 seconds
{right}Fast-forward 5 seconds
{up}Turn Volume Up
{down}Turn Volume Down
74 |

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 | #ClipboardTimeout - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

#ClipboardTimeout

14 | 15 |

Changes how long the script keeps trying to access the clipboard when the first attempt fails.

16 | 17 |
#ClipboardTimeout Milliseconds
18 |

Parameters

19 |
20 | 21 |
Milliseconds
22 |

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.

23 | 24 |
25 |

Remarks

26 |

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".

28 |

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 | 32 |

Clipboard, Thread

33 |

Examples

34 |
35 |

Causes the script to wait 2 seconds instead of 1 second before giving up accessing the clipboard and displaying an error message.

36 |
#ClipboardTimeout 2000
37 |
38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/commands/ListHotkeys.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ListHotkeys - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

ListHotkeys

14 | 15 |

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 | 31 | 32 | 33 |

#InstallKeybdHook, #InstallMouseHook, #UseHook, KeyHistory, ListLines, ListVars, #MaxThreadsPerHotkey, #MaxHotkeysPerInterval

34 |

Examples

35 |
36 |

Displays information about the hotkeys used by the current script.

37 |
ListHotkeys
38 |
39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /docs/commands/WinMaximize.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinMaximize - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

WinMaximize

14 | 15 |

Enlarges the specified window to its maximum size.

16 | 17 |
WinMaximize , WinTitle, WinText, ExcludeTitle, ExcludeText
18 |

Parameters

19 |
20 | 21 |
WinTitle
22 |

A window title or other criteria identifying the target window. See WinTitle.

23 | 24 |
WinText
25 |

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.

26 | 27 |
ExcludeTitle
28 |

Windows whose titles include this value will not be considered.

29 | 30 |
ExcludeText
31 |

Windows whose text include this value will not be considered.

32 | 33 |
34 | 35 |

Remarks

36 |

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_MAXIMIZE
39 |

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 | 42 |

WinRestore, WinMinimize

43 |

Examples

44 |
45 |

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 |
50 | 51 |
52 |

Press a hotkey to maximize the active window.

53 |
^Up::WinMaximize, A  ; Ctrl+Up
54 |
55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /docs/commands/SoundGetWaveVolume.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SoundGetWaveVolume - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

SoundGetWaveVolume

15 | 16 |

Retrieves the wave output volume of a sound device.

17 | 18 |
SoundGetWaveVolume, OutputVar , DeviceNumber
19 |

Parameters

20 |
21 | 22 |
OutputVar
23 |

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.

24 | 25 |
DeviceNumber
26 |

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.

27 | 28 |
29 |

Error Handling

30 |

[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 |

Remarks

33 |

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.

35 | 36 |

SoundSetWaveVolume, SoundSet, SoundGet, SoundPlay

37 |

Examples

38 |
39 |

Retrieves and reports the current wave output volume.

40 |
SoundGetWaveVolume, OutputVar
41 | MsgBox, The current wave output volume level is %OutputVar%`%.
42 |
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /docs/commands/Shutdown.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Shutdown - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Shutdown

14 | 15 |

Shuts down, restarts, or logs off the system.

16 | 17 |
Shutdown, Flag
18 |

Parameters

19 |
20 | 21 |
Flag
22 |
23 |

A combination (sum) of the following numbers:

24 | 31 |

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 |
35 | 36 |
37 | 38 |

Remarks

39 |

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 | 43 |

Run, ExitApp, OnExit(), OnExit

44 |

Examples

45 |
46 |

Forces a reboot (reboot + force = 2 + 4 = 6).

47 |
Shutdown, 6
48 |
49 | 50 |
51 |

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 |
57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /docs/commands/WinSetTitle.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinSetTitle - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

WinSetTitle

14 | 15 |

Changes the title of the specified window.

16 | 17 |
18 | WinSetTitle, NewTitle
19 | WinSetTitle, WinTitle, WinText, NewTitle , ExcludeTitle, ExcludeText
20 | 
21 |

Parameters

22 |
23 | 24 |
NewTitle
25 |

The new title for the window. If this is the only parameter given, the Last Found Window will be used.

26 | 27 |
WinTitle
28 |

A window title or other criteria identifying the target window. See WinTitle.

29 | 30 |
WinText
31 |

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.

32 | 33 |
ExcludeTitle
34 |

Windows whose titles include this value will not be considered.

35 | 36 |
ExcludeText
37 |

Windows whose text include this value will not be considered.

38 | 39 |
40 | 41 |

Remarks

42 |

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 | 45 |

WinMove, WinGetActiveStats, WinGetActiveTitle, WinGetText, ControlGetText, WinGetPos, WinSet

46 |

Examples

47 |
48 |

Changes the title of Notepad.

49 |
WinSetTitle, Untitled - Notepad, , This is a new title
50 |
51 | 52 |
53 |

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 |
58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /docs/commands/Exit.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exit - Syntax & Usage | AutoHotkey 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Exit

14 | 15 |

Exits the current thread or (if the script is not persistent) the entire script.

16 | 17 |
Exit , ExitCode
18 |

Parameters

19 |
20 | 21 |
ExitCode
22 |

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.

23 | 24 |
25 | 26 |

Remarks

27 |

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 | 32 |

ExitApp, OnExit(), OnExit, Functions, Gosub, Return, Threads, #Persistent

33 |

Examples

34 |
35 |

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 |
44 | 45 | 46 | 47 | --------------------------------------------------------------------------------