keepcalculator

06 Numbers and Powers

Favorite AutoHotkey Scripts: Top Picks

Card No. 06·49487 · Updated · Standard formula, shown below

People’s favorite AutoHotkey scripts are usually the ones that save them the most repetitive typing or clicking. This article lists the most commonly shared and genuinely useful scripts, explains how they work, and shows you how to adapt them to your own workflow.

What Makes a Script a “Favorite”?

AutoHotkey (AHK) is a free, open-source scripting language for Windows that automates keystrokes, mouse clicks, and window management. A script is a plain-text file with the .ahk extension. When you run it, AHK interprets the commands and performs the actions. Favorites tend to be short, reliable, and solve a problem you hit dozens of times a day. They often fall into these categories:

  • Text expansion – type a short abbreviation and get a full phrase, address, or code snippet.
  • Window management – move, resize, or snap windows with hotkeys instead of dragging with the mouse.
  • Clipboard enhancements – save multiple clipboard items and paste them later.
  • App-specific shortcuts – add missing shortcuts to programs like Excel, Notepad, or your browser.
  • Mouse and keyboard remapping – swap keys, disable CapsLock, or make the mouse wheel do something else.

Text Expansion Scripts

The most popular text expansion script is a simple hotstring. Hotstrings trigger when you type a certain sequence of characters followed by an ending character (space, period, or Enter). A classic example:

::sig::
Best regards,
John Smith
Sales Manager
(555) 123-4567

When you type sig and then press space, AHK replaces it with the full signature block. You can create hotstrings for your email address, your phone number, or even long boilerplate paragraphs. For example:

::addr::123 Main Street, Springfield, IL 62704
::email::john.smith@example.com

To make sure the abbreviation doesn’t trigger inside a word, add the ? option or use the * option to trigger without an ending character. The B0 option deletes the abbreviation before pasting the replacement. For instance:

:*:btw::by the way

That will expand btw even if you type it in the middle of a word. Most people start with a handful of hotstrings for their own name, address, and common phrases.

Window Management Scripts

Window management is another favorite category because moving and resizing windows with the mouse is slow. A simple script that snaps the active window to the left half of the screen:

#Left::
WinGetPos, , , W, H, A
WinMove, A, , 0, 0, W/2, H
return

Here #Left means Win+Left arrow. The script gets the current window’s width and height, then moves it to the top-left corner with half the width. You can extend this to all four corners:

#Up::WinMove, A, , 0, 0, W, H/2
#Right::WinMove, A, , A_ScreenWidth/2, 0, W/2, H

But you don’t need to write these from scratch. The built-in WinMove command and the WinGetPos function are enough. Many users also like to make a window always-on-top with a hotkey:

^SPACE::  Winset, AlwaysOnTop, Toggle, A

That toggles the always-on-top attribute for the active window with Ctrl+Space. This is handy for keeping a reference window visible while you work in another.

Clipboard Enhancements

Windows only keeps one clipboard item. A favorite script stores multiple items so you can paste them later. A simple implementation uses an array and a hotkey to save the current clipboard:

^+c::
clipboard := clipboard
ClipboardArray.Insert(clipboard)
ToolTip, Copied!
Sleep, 500
ToolTip
return

Then a hotkey to show a menu of saved items:

^+v::
Menu, ClipboardMenu, Add, 1, PasteItem
; ... add all items ...
Menu, ClipboardMenu, Show
return

A more complete version uses a ListView or a simple GUI, but the core idea is the same. Another popular clipboard trick is to paste plain text (stripping formatting) with a hotkey:

^+v::
clipboard := clipboard
SendInput, {Ctrl down}v{Ctrl up}
return

That copies the clipboard as plain text when you press Ctrl+Shift+V. Note that this only works if the clipboard contains text; if it contains an image, it will paste the image.

App-Specific Shortcuts

Many people create scripts that add shortcuts to a particular program. For example, in Excel you might want to insert the current date with a hotkey:

#IfWinActive ahk_class XLMAIN
^d::
FormatTime, CurrentDate,, yyyy-MM-dd
SendInput, %CurrentDate%
return
#IfWinActive

The #IfWinActive directive makes the hotkey only work when Excel is active. The ahk_class XLMAIN is the internal class name for Excel’s main window. Similarly, you can create shortcuts for Notepad, browsers, or any application. A common one is to open a specific website with a hotkey:

^!g::Run, https://www.google.com

That opens Google with Ctrl+Alt+G. You can also use Run to launch programs:

^!n::Run, notepad.exe

Key Remapping and Mouse Fixes

Remapping keys is one of the most common reasons people install AutoHotkey. The syntax is simple:

CapsLock::Ctrl

That makes CapsLock act as a Ctrl key. To swap two keys, you need to use the * modifier to avoid stuck keys:

*CapsLock::Ctrl
*Ctrl::CapsLock

But remapping keys can cause issues if you use the original keys in shortcuts. A safer approach is to use the #InstallKeyBDHook directive at the top of the script. Another popular remap is to make the right Alt key act as a second Windows key:

RAlt::LWin

Mouse fixes are also common. If your mouse has a button that does something annoying, you can disable it:

XButton1::return

That makes the side button (XButton1) do nothing. You can also make the mouse wheel scroll horizontally when you hold Shift:

+WheelUp::Send {WheelLeft}
+WheelDown::Send {WheelRight}

How to Choose and Test Scripts

When you find a script online, read it carefully. Look for the commands Send, WinMove, Run, and Hotkey. Make sure the hotkeys don’t conflict with existing shortcuts you use. For example, ^c is Ctrl+C, which you probably don’t want to override. Test each script in a text editor first to see what it does. You can run a script by double-clicking the .ahk file. To stop it, right-click the green H icon in the system tray and select Exit. If a script misbehaves, you can pause it from the tray menu.

Common Mistakes and Troubleshooting

One frequent mistake is forgetting to include the return at the end of a hotkey subroutine. Without it, the script continues to the next line, which can cause unexpected behavior. Another is using Send with special characters that need escaping. For example, to send a literal ! you must write {!}. Similarly, # is a modifier, so to send a hash symbol you use {#}.

If a hotkey doesn’t work, check if the script is actually running (look for the tray icon). Also, some applications (like games) may block simulated keystrokes. In that case, you might need to use SendInput or SendPlay instead of Send. If you’re using a laptop with a function key, make sure the Fn key isn’t interfering.

Alternatives to AutoHotkey

AutoHotkey is not the only automation tool. Alternatives include:

  • AutoIt – similar to AutoHotkey but with a BASIC-like syntax.
  • Pulover’s Macro Creator – a graphical interface that generates AutoHotkey code.
  • PhraseExpress – a commercial text expansion tool with a GUI.
  • PowerToys – Microsoft’s free utility that includes a text expander and window management features.

AutoHotkey is free and very flexible, but it has a learning curve. If you only need text expansion, a dedicated tool might be simpler. However, for deep customization, AutoHotkey is hard to beat.

Frequently Asked Questions

Is AutoHotkey safe to download?

Yes, AutoHotkey is open-source and widely used. Download it only from the official website (autohotkey.com) to avoid modified versions. Always scan any downloaded script with an antivirus before running it, since scripts can contain malicious commands.

Can AutoHotkey scripts be compiled into .exe files?

Yes, you can compile an .ahk script into a standalone .exe using the Ahk2Exe compiler that comes with AutoHotkey. This allows you to run the script on computers without AutoHotkey installed, but some antivirus programs may flag compiled scripts as suspicious.

Will AutoHotkey work on Windows 11?

Yes, AutoHotkey works on Windows 11. However, some older scripts that rely on deprecated features may need minor adjustments. The current version (v2) is recommended for new scripts, but v1.1 is still widely used and supported.

How do I make a script run on startup?

Place a shortcut to the .ahk file (or the compiled .exe) in the Startup folder. You can open the Startup folder by pressing Win+R and typing shell:startup. Alternatively, you can use a script to add itself to the registry.

Can AutoHotkey automate games?

It can, but many games have anti-cheat systems that detect simulated input and may ban you. Using AutoHotkey to automate gameplay is generally against the terms of service of most online games. For offline games, it’s usually fine, but be cautious.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →