Skip to content

How-ToOS

How to Use AutoHotkey v2 to Remap Keys, Create Hotkeys and Text Shortcuts

How to use AutoHotkey v2, the free open-source Windows scripting tool, to remap keys and mouse buttons, create hotkeys and text shortcuts: safe download, your first script, one-line remaps such as Caps Lock to Ctrl, per-app rules with #HotIf, hotstrings, running at startup, admin windows, games and registry remapping.

By , Systems & Technical Editor

6 min read

How to Use AutoHotkey v2 to Remap Keys, Create Hotkeys and Text Shortcuts

The steps and script examples come from AutoHotkey's official website and v2 documentation, plus the project's GitHub release page, all checked on 25 November 2026.

Most gaming keyboards and mice come with software that can remap buttons, but it generally only works with that brand's hardware. AutoHotkey isn't tied to one brand, costs nothing and can do far more than swap keys. Its website describes it as a free, open-source scripting language for Windows, licensed under the GNU GPLv2, for tasks such as hotkeys, remapping keys or buttons, autocorrect-like text replacements, form fillers, auto-clicking and macros.

If you only want a couple of simple key swaps with a graphical tool, our Microsoft PowerToys guide and the best free keyboard and mouse remapping software round-up cover easier options. If your keyboard runs QMK or VIA firmware, remapping it with VIA changes the keyboard itself. AutoHotkey is the tool to reach for when you want per-app rules, text expansion or small automations.

Step 1: Download AutoHotkey v2

Download AutoHotkey only from autohotkey.com or the project's GitHub releases page. The website notes that v2 is now the default, main version, and the documentation is split into separate v1 and v2 versions, so make sure any examples you copy are written for v2.

The latest v2 release on GitHub at the time of writing was v2.0.32, published on 20 November 2026, available as an installer (AutoHotkey_2.0.32_setup.exe) and a zip. The official tutorial recommends the installer because it's easiest to set up: run it and click Install.

The AutoHotkey FAQ notes that antivirus programs sometimes flag AutoHotkey or compiled scripts, and says most such alerts are false positives. It suggests checking the file with an online multi-engine scanner such as VirusTotal if you're unsure. That only applies to files from the official sources; never run a script or .exe from a stranger without reading it first.

Step 2: Create and run your first script

The official tutorial's steps are:

  1. Right-click on your desktop and choose New > AutoHotkey Script.

  2. Give it a name ending in .ahk, such as MyScript.ahk.

  3. Right-click the new file and choose Edit Script. It will probably open in Notepad.

  4. Add this hotkey, then save the file:

^j::
{
    Send "My First Script"
}
  1. Double-click the file to run it, open Notepad (or anything you can type in) and press Ctrl+J.

In that example, ^j:: is the hotkey (^ means Ctrl), Send types the text and the braces mark the start and end of what the hotkey does. The Hotkeys documentation lists the other modifier symbols: ! for Alt, + for Shift and # for the Windows key, and you can combine them, as in ^!s for Ctrl+Alt+S.

A running script has a tray icon; the documentation notes its menu includes Help. After editing a script, run it again so your changes take effect.

Step 3: Remap keys and mouse buttons

Remapping is a single line: OriginKey::DestinationKey. Examples from AutoHotkey's remapping documentation:

Line

What it does

a::b

Makes A behave like B

CapsLock::Ctrl

Turns Caps Lock into Ctrl

XButton1::LButton

Makes the fourth mouse button act as a left click

XButton2::^LButton

Makes the fifth mouse button do a Ctrl+click

MButton::Shift

Makes the middle mouse button act as Shift

RAlt::AppsKey

Makes right Alt open the context (Menu) key

RWin::Return

Disables the right Windows key

Two details from the documentation are worth knowing:

  • Lowercase is usually best. a::b also remaps capitals, following Caps Lock and Shift. An uppercase destination such as a::B forces a capital.

  • Keep Caps Lock available. If you turn Caps Lock into Ctrl, add +CapsLock::CapsLock above it, so Shift+Caps Lock still toggles it. The more specific line must come first.

The remapping page refers to the side mouse buttons as XButton1 and XButton2. The FAQ explains that extra buttons only work if your mouse driver lets Windows see them; if not, set them to send a keyboard shortcut in the mouse's own software, then use that shortcut as a hotkey.

Step 4: Limit a remap or hotkey to one app

You often want a change only in one program, such as a game or an editing app. AutoHotkey's #HotIf directive does this. The documentation's example:

#HotIf WinActive("ahk_class Notepad")
a::b  ; Makes the 'a' key send a 'b' key, but only in Notepad.
#HotIf  ; Everything below works in all windows again.

#HotIf affects every hotkey and remap below it until the next #HotIf, so group app-specific lines together. You can match a window by its title, as in the tutorial's WinActive("Untitled - Notepad") example, or by class as above.

Step 5: Add text shortcuts (hotstrings)

Hotstrings replace an abbreviation with longer text as you type. From the documentation:

::btw::by the way

By default, you type an ending character such as Space, full stop or Enter after the abbreviation to trigger it, and AutoHotkey deletes the abbreviation automatically. Add the asterisk option to trigger it immediately without an ending character:

:*:j@::jsmith@somedomain.com

Hotstrings are handy for email addresses, addresses, support replies and common commands.

Step 6: Run your script every time Windows starts

The FAQ's easiest method is a shortcut in your Startup folder:

  1. Select the script file and press Ctrl+C.

  2. Press Win+R, type shell:startup and press Enter. This opens the Startup folder for your user account.

  3. Right-click inside the folder and choose Paste Shortcut.

To manage it later alongside your other startup programs, see our guide to managing startup apps in Windows 11.

If a hotkey doesn't work

  • Admin windows. The FAQ explains that User Account Control blocks a normal script from sending input to programs running as administrator, and blocks its hotkeys there too. Its recommended fix is to run the script with UI access (right-click the script and choose Run with UI access; on Windows 11 this may be under Show more options), which requires AutoHotkey to be installed under Program Files. Running the script as administrator also works, but anything it launches will run as administrator too.

  • Games. The FAQ warns that not all games let AutoHotkey send keys and clicks, and that games with cheat prevention measures may not work with it at all. The remapping page also notes that some games don't support remapping. Check a game's own rules before using macros or automated input in online or competitive titles.

  • Lag under heavy load. If hotkeys feel slow while the CPU is busy, the FAQ suggests adding ProcessSetPriority "High" near the top of the script.

  • A script won't start. Fix the error it reports first; the FAQ notes you can't edit a script via its tray icon until it starts.

Registry remapping: the alternative

AutoHotkey's own documentation is candid that its remapping is "generally not as pure and effective" as remapping through the Windows registry's Scancode Map. Registry remaps work in more games and don't need anything running in the background, but they apply to every app and user, need a reboot to change, only cover the keyboard and can't send Shift, Ctrl or Alt combinations. For a permanent one-key fix, such as disabling a key you keep hitting by accident, the registry route can be the better choice; for anything per-app, mouse-related or text-based, AutoHotkey wins.

Our verdict

AutoHotkey v2 is the most flexible free way to remap keys and mouse buttons, add hotkeys and set up text shortcuts on Windows 11, and it isn't tied to one brand of keyboard or mouse. Download it from autohotkey.com, start with one-line remaps such as CapsLock::Ctrl, use #HotIf to keep changes to the right app, and put a shortcut in shell:startup so your script runs every time. Be careful with games: the FAQ warns some won't work with it, and you should check a game's rules before using macros.

The bottom line

AutoHotkey v2 is the most flexible free way to remap keys and mouse buttons, add hotkeys and set up text shortcuts on Windows 11, and it isn't tied to one brand of keyboard or mouse. Download it from autohotkey.com, start with one-line remaps such as CapsLock::Ctrl, use #HotIf to keep changes to the right app, and put a shortcut in shell:startup so your script runs every time. Be careful with games: the FAQ warns some won't work with it, and you should check a game's rules before using macros.

Sources

  1. 01AutoHotkey: official website
  2. 02AutoHotkey v2 documentation: Beginner tutorial
  3. 03AutoHotkey v2 documentation: Remapping keys
  4. 04AutoHotkey v2 documentation: Hotkeys
  5. 05AutoHotkey v2 documentation: Hotstrings
  6. 06AutoHotkey v2 documentation: FAQ
  7. 07AutoHotkey: v2.0.32 release on GitHub

About the author

Marcus Thorne

Systems & Technical Editor

Marcus writes Forge PC's step-by-step build, troubleshooting and system optimisation guides. His background spans Windows kernel and power-state diagnostics, UEFI/BIOS configuration, NVMe storage arrays, ATX 3.1 power delivery and running local AI and LLM workloads on consumer graphics cards.

More from Marcus Thorne

Read next

Best Free Photo Editors for Windows 11 in 2026

Best Picks

Best Free Photo Editors for Windows 11 in 2026

The best free photo editors for Windows 11 in 2026: GIMP as the best overall, Paint.NET for beginners and quick edits, Photopea in the browser and for PSD files, darktable for raw photos and Krita for painting and retouching, with versions, licences and Windows requirements.

Hannah Vance6 min

LibreOffice vs ONLYOFFICE: Which Free Office Suite Is Best for Your PC?

Versus

LibreOffice vs ONLYOFFICE: Which Free Office Suite Is Best for Your PC?

LibreOffice vs ONLYOFFICE Desktop Editors on a Windows 11 PC in 2026: apps included, Microsoft Office file compatibility, tabbed interface, PDF and form editing, optional AI tools and local models, cloud collaboration, licences and Windows system requirements, and which free office suite suits which user.

Callum Reid6 min

How to Change Default Apps in Windows 11

How-To

How to Change Default Apps in Windows 11

How to change default apps in Windows 11: using Open with > Choose another app with Always or Just once, the file Properties method, setting defaults by file type, link type or app in Settings > Apps > Default apps, changing your default browser, resetting all default apps and fixing common problems.

Marcus Thorne7 min

Windows ML Gets DX CGC: Microsoft's New Way to Run Local AI on Your GPU

News

Windows ML Gets DX CGC: Microsoft's New Way to Run Local AI on Your GPU

Microsoft's Windows ML 2.9.42 Experimental adds DX CGC, a DirectX-based compiler for running AI models on graphics cards, with NVIDIA acceleration first via the 621.24 driver, plus direct loading of GGUF and Hugging Face models. We explain what's new and what it means for local AI on Windows.

Eleanor Shaw5 min