Skip to content

AutoHotKey

An open-source scripting programming language for Windows!

Basics

  • An elevated AHK process will start elevated processes by default

Hotstrings

  • Hotkey is created by single pair of colons, like ::mail::[email protected]
    • If the hotstring contains an emoji, save the file in UTF-8 BOM format - See documentation
  • Hotstrings can have options
    • Case-insensitive by default
    • An ending character must be typed, except if asterisk option with :*: at the start

Input trigger

Keyboard & Mouse

Symbol Description
# Windows key
! Alt key
^ Ctrl key
+ Shift key
& Combine keys/mouse buttons, like Numpad0 & Numpad1::
$ Only trigger with the exact key + avoid self-trigger

Examples

^j::
Send, My first script
return

; Comment

^!F11::Send {F11} ; Send F11 when pressing Ctrl+Alt+F11
$F11::Send {Home} ; Send Home when pressing F11

Window-specific

An action can be enabled in a certain window thanks to a directive (#).
This affects all hotkeys/Hotstring beneath them in the script, and only the most recent is in effect.
More detail in doc

; Untitled - Notepad
#IfWinActive Untitled - Notepad
!q::
MsgBox, You pressed ALT+Q in Notepad.
return

; Any window that isn't Untitled - Notepad
#IfWinActive
!q::
MsgBox, You pressed ALT+Q in any window.
return

Launch a command unelevated from an elevated script

  • Use ShellRun
  • And call it like ShellRun("command.exe")

Reference