Useful AutoHotkey Scripts

By Xah Lee. Date: . Last updated: .

This page is a collection of useful AutoHotkey scripts. [see AutoHotkey Tutorial]

Useful Simple Key Remap

Here are examples of simple key remap. Note, for simple key remap, you should use Microsoft PowerToys, because it's easier to use and more reliable.

Right Win as App Key

; make the right Win key behave as AppsKey
RWin::AppsKey

[see AutoHotkey Key Syntax]

Single Key to Switch Previous Window

It is useful to have a single button to switch to last window.

; set Left Windows Key for switching to previous window/app
$LWin::Send !{Tab}

Single Key for Cut, Copy, Paste

$F2::Send ^x ; cut
$F3::Send ^c ; copy
$F4::Send ^v ; paste

Close Tab

; Pause/Break key close current tab
Pause::Send ^w

Switch to Previous/Next Tab

; F11 and F12 do switch prev/next tab
$F11::Send ^{PgUp}
$F12::Send ^{PgDn}

Empty Recycle Bin

; Win+Del to empty recycle bin
$#Del::FileRecycleEmpty

Open recycle bin:

; open recycle bin
$F5::RUN ::{645ff040-5081-101b-9f08-00aa002f954e}

Change Sound Volume

Many keyboards have special buttons to control sound level, but they are a pain to use. Because, the button change volume by a tiny amount. You have to press it 5 or 10 times. If you hold it, for a second nothing happens, then all of a sudden it became too loud.

The following script changes volume by 10%, using Ctrl and the + and - on the numberpad.

;; Win+NumpadSub decrease sound volume, Win+NumpadAdd increase sound volume
$#NumpadAdd::Send {Volume_Up 5}
$#NumpadSub::Send {Volume_Down 5}

Change Sound Level with Multimedia Key

If you have a keyboard with multimedia keys such as Microsoft Ergonomic Keyboard, and want increase sound volume by one of its special button, here's what you can do.

Create a file of the following content and save it as increase_sound.ahk:

#NoTrayIcon
Send {Volume_Up 5}

Then, use IntelliType to assign the keyboard's special button to launch the script.

Temporarily Disable AutoHotkey

You have many personal hotkeys. In some situations, you want these hotkeys to be off temporarily. You can create a hotkeyX, so that it'll disable all your hotkeys, and press hotkeyX again to turn all your hotkeys back on. Here's a example:

; make the scroll lock key (ScrLk) toggle all hotkeys.
$ScrollLock::Suspend

When hotkeys are suspended, the AutoHotkey icon in your system notification area changes to S.

Swap Middle/Right Mouse Buttons

Windows: Swap Mouse Right-Click Middle-Click

AutoHotkey Tutorial

AutoHotkey logo nz9fX