AutoHotkey hotkeys

A hotkey is a key combination bound to an action. In AutoHotkey the binding is one line: the keys on the left of ::, the action on the right.

#Requires AutoHotkey v2.0

^!n::Run "notepad.exe"

Modifier symbols

SymbolKey
^Ctrl
!Alt
+Shift
#Windows
< / >Left or right side of a modifier pair
*Fire regardless of other modifiers held
~Let the original keystroke through as well

More than one line of work

^!d::
{
    Send FormatTime(A_Now, "yyyy-MM-dd")
    Send "{Enter}"
}

Hotkeys that only exist in one app

#HotIf WinActive("ahk_exe explorer.exe")
F2::Send "{F2}"
^n::Send "^+n"
#HotIf

Mouse buttons count too

XButton1::Send "!{Left}"
XButton2::Send "!{Right}"
^WheelUp::Send "^{PgUp}"

Remapping a key

CapsLock::Ctrl
Insert::Delete

A remap is a hotkey whose action is another key. It applies system-wide while the script runs and leaves the physical keyboard untouched.

When a shortcut does not fire

For step-by-step practice, see writing hotkeys in the reference, or browse ready-made bindings on the scripts page.

Frequently asked questions

How do I create a keyboard shortcut in Windows with AutoHotkey?

Write the key combination, then two colons, then the action — for example ^!n::Run "notepad.exe" — and run the script.

Can I limit a hotkey to one application?

Yes. Wrap the hotkey in #HotIf WinActive("ahk_exe name.exe") and close the block with a bare #HotIf.

How do I remap a key?

Write the physical key, two colons, then the key it should produce, such as CapsLock::Ctrl.


AutoHotkeyTools.com is an independent Windows resource covering AutoHotkey tools, scripts, hotkeys, tutorials and desktop automation. It is not affiliated with the AutoHotkey project.