AutoHotkey Tutorial

By Xah Lee. Date: . Last updated: .

What is AutoHotkey

AutoHotkey logo nz9fX

AutoHotkey is a keyboard macro software for Microsoft Windows. It is free.

For example, you can:

Download AutoHotkey

Download at http://www.autohotkey.com/

AutoHotkey Version 1 vs Version 2

Create Script

To create a AHK script, copy paste the following text into a file, save and name it test.ahk

; sample AutoHotkey file
; showing basics

#Requires AutoHotkey v2.0

; hotstring. typing btw expands
::btw::by the way

; set key to type text
F3::
{
Send "something in the water."
}

; Win+n
; launch notepad
#n::Run "Notepad"

; Alt+n
; open documents folder
!n::
{
Run("c:/Users/xah/Documents/")
}

; Ctrl+n
; open downloads folder
^n::
{
Run("c:/Users/xah/Downloads/")
}

; make insert key do f11 (fullscreen)
ins::f11

; paste
F2::Send "^v"

; close tab
F1::send "^w"

; previous tab, next tab
pgup::Send "^+{Tab}"
pgdn::Send "^{Tab}"

; previous window
ScrollLock::Send "!{Tab}"

; copy url in current browser
F7::
{
Send "^l"
Sleep 100
Send "^c"
Sleep 100
Send "!{Tab}"
}

; insert date. control+alt+d
^!d::
{
currentDate := FormatTime(A_Now, "yyyy-MM-dd")
Send(currentDate)
}

Run Script

To run ahk script, double click it.

ahk script 2022-12-03 c293d
ahk script 2022-12-03

Exit AutoHotkey

Right-click on the AutoHotkey icon in taskbar, and pull a menu to exit the script.

If you exit, your hotkeys will not work anymore.

AutoHotkey v2 2025-11-01 20a4a
AutoHotkey v2 2025-11-01 20a4a

AutoHotkey help

AutoHotkey help 2025-11-02 11ef0
AutoHotkey help 2025-11-02 11ef0
AutoHotkey help 2025-11-02 138fe
AutoHotkey help 2025-11-02 138fe

Start an AutoHotkey Script When Windows Starts