Advanced Hotkey Features


Users of Windows NT/2000/XP and beyond may take advantage of the following additional features, some of which are unique to AutoHotkey and not available even in the most powerful commercial hotkey software.

Some of the easiest keys to reach on the keyboard are also the least frequently used. Make these keys do something useful! For example, if you rarely use the right ALT key, make it perform the action you do most often:

RAlt::
MsgBox You pressed the right ALT key.
return

You can even do the above without losing Right-ALT's native function by assigning Right-ALT to be a "prefix" for at least one other hotkey. In the below example, Right-ALT has become a prefix, which automatically allows it to modify all other keys as it normally would. But if you press and release Right-Alt without having used it to modify another key, its hotkey action (above) will take effect immediately:
RAlt & j::AltTab

 

Don't be limited to using only CTRL, ALT, SHIFT, and WIN as modifiers; you can combine any two keys or mouse buttons to form a custom hotkey. For example: Hold down Numpad0 and press Numpad1 to launch a hotkey (syntax: Numpad0 & Numpad1::); hold down CapsLock and press another key, or click a mouse button (syntax: CapsLock & RButton::). In this case, the state of the CapsLock key is not changed when it is used to launch the hotkey.

 

Convert the mouse wheel (or any other keys of your choice) into a complete substitute for Alt-Tab. Click the wheel to show or hide the menu, and turn it to navigate through the menu. The wheel will still function normally whenever the Alt-Tab menu isn't visible. Syntax:

MButton::AltTabMenu
WheelDown::AltTab
WheelUp::ShiftAltTab

 

Make a keyboard key become a mouse button, or have an action repeated continuously while you're holding down a key or mouse button. See the remapping page for examples.

 

Make your hotkeys context-sensitive: Have your easiest-to-reach hotkeys perform an action appropriate to the type of window you're working with. For example:

RControl::  ; The right Control key.
IfWinActive, Untitled - Notepad
{
	WinMenuSelectItem, , , File, Save  ; Save the current file.
}
else IfWinActive, Calculator
{
	Send, ^c!{tab}^v  ; Copy the calculated value into the previously active window. 
}
return
 

Hot-strings: Define abbreviations that expand as you type them. No special training or scripting experience is needed. For example, a script containing the following lines would expand ceo, cfo, and btw wherever you type them:

::ceo::Chief Executive Officer
::cfo::Chief Financial Officer
::btw::by the way

(more details)

 

Of special interest for gaming:

See the Hotkeys section for more detailed information.