An AutoHotkey script is a plain text file with an .ahk extension. Lines run top to bottom when the file loads, and any hotkey definitions stay resident afterward, waiting for their key. That is the whole model — everything below is a variation on it.
.ahk.#Requires AutoHotkey v2.0 ^!e::Run "explorer.exe" ^!t::Run "wt.exe" ^!b::Run "https://autohotkeytools.com/"
::addr::1 Market Street, Suite 400 ::brb::be right back :*:sig::Best regards,`nAlex
The colons mark a hotstring. The * option fires without waiting for a space or punctuation, and `n inserts a line break.
^!v::
{
text := A_Clipboard
text := StrReplace(text, "`r`n", " ")
A_Clipboard := Trim(text)
Send "^v"
}
This flattens a multi-line copy into one line before pasting it — useful when moving text out of a PDF.
#Left::WinMove 0, 0, A_ScreenWidth / 2, A_ScreenHeight, "A" #Right::WinMove A_ScreenWidth / 2, 0, A_ScreenWidth / 2, A_ScreenHeight, "A"
#HotIf WinActive("ahk_exe chrome.exe")
^q::Send "^w"
#HotIf
Between the two #HotIf lines, the hotkey only exists while Chrome is in front. Everywhere else, Ctrl+Q keeps its normal meaning.
#Requires AutoHotkey v2.0.Send over mouse coordinates; keyboard paths survive layout changes.More finished code lives on the examples page, and the productivity page groups scripts by the kind of work they save.
Save a text file with the .ahk extension, add your code, and double-click the file to run it.
Any folder works. A single scripts folder, with a shortcut to your main file in the Startup folder, keeps things simple.
Right-click the tray icon and choose Reload, or add a hotkey that calls Reload.