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:

  • Set F8 to launch browser, and just switch to it if it is already running.
  • Set F3 to Copy, F4 to Paste, F12 to close a browser tab.
  • Swap Alt and Ctrl keys.
  • Disable ❖ Window key, or CapsLock, NumLock, ScrollLock keys, or make them do something useful.
  • Set a key to insert today's date.
  • Set a key to insert template text, such as your address.

Download AutoHotkey

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

AutoHotkey Version 1 vs Version 2

  • Version 1.x began in 2003. It is legacy as of 2023. No longer maintened.
  • Version 2 began in 2021. It is incompatible with version 1. It is the current version.

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

AltStyle によって変換されたページ (->オリジナル) /