Autohotkey symbols

10 Cool AutoHotkey Scripts (And How to Make Your Own!)

If you're familiar with the many keyboard shortcuts in Windows and still feel like you need more, it's time to move onto an advanced tool that lets you make your own scripts.

AutoHotkey (AHK) is the answer to your customization needs. This program lets you remap keys, create custom shortcuts, run macros to automate repetitive tasks, and more.

Let's look at some useful AutoHotkey scripts to get you started, along with the basics of the software so you can make your own.

How to Install AutoHotkey

Before you can use cool AHK scripts or make your own, you'll need to install AutoHotkey on your system.

Visit AutoHotkey's homepage, click Download, and choose Download Current Version to grab it. Run through the quick install dialog, and you're ready to start using AutoHotkey scripts.

How to Create New AutoHotkey Scripts

The program you just installed handles the execution of AHK scripts, but it won't do anything until you actually have a script running.

To create a new AutoHotkey script, right-click anywhere on your desktop (or wherever else is convenient) and choose New > AutoHotkey Script. Name it something that makes sense. Then right-click on your new file and choose Edit Script, or open the file in your text editor of choice, to start working on it.

Note that you can also open your text editor, type up an AutoHotkey script, and save it as a file ending in .ahk to achieve the same result. Just make sure it has the right file extension!

Speaking of this, it's a good idea to upgrade your text editor from the basic Notepad. Notepad++ and Visual Studio Code are both great free options.

Now that you have the software to run AutoHotkey scripts, you can download scripts that others have written to take advantage of them without doing any work on your own. To save one, simply download it as an .ahk file and save it wherever you wish.

To run a script, simply double-click on it and it will go into effect. However, you'll probably want some of these scripts to run as soon as you boot your computer so you don't have to start them manually every time.

To do so, copy and paste the .ahk files into your Startup folder. You can get there easily by typing shell:startup into the Start menu. Otherwise, browse to the following location:

Doing this loads your AutoHotkey scripts once you log into your computer.

The Best AutoHotkey Scripts to Try

Here are some of the most useful AutoHotkey scripts you can download and use to improve Windows right away. For even more AutoHotkey script examples, including ones that are much more complex than these, check out the AutoHotkey Script Showcase.

1. AutoCorrect

Even with the precision of a desktop keyboard, you're still bound to make mistakes when typing. And while this is an old AHK script, typos don't go out of style.

Related: How to Enable the Built-In Autocorrect in Windows 10

It contains thousands of common misspellings—when you make a mistake, it instantly replaces your error with the correct word. It even allows you to add your own words, which we'll discuss later.

Download: AutoCorrect Script

2. Disable Lock Keys

The three Lock keys—Num Lock, Caps Lock, and Scroll Lock—aren't used that often in today's computing. You probably use the number pad solely for digits, only hit Caps Lock by accident, and don't even care about Scroll Lock.

If you rarely use these modifiers, try setting them to a default value with this script:

This assumes you want Num Lock always on. If you prefer it off, just change that line (or remove it completely and only change Caps Lock and Scroll Lock).

3. Re-Purpose Caps Lock

Once you've used the above script to disable Caps Lock, it makes sense to give that key another purpose.

Using this short script will turn Caps Lock into another Shift key, but you can change it to anything you'd like (perhaps another Windows key, if your keyboard only has one of those):

4. Quickly View or Hide Hidden Files

It's important to know how to view hidden files and folders in Windows at times. If you only need access to hidden folders once in a while and don't want them cluttering up your view normally, this is a useful script.

This script simply has you press Ctrl + F2 with File Explorer open to toggle showing hidden files or folders. That's all there is to it! You'll just need to copy the code from the linked forum post into a script:

Visit:Toggle Hidden Files Script

5. Quickly Show or Hide Known File Extensions

This one is similar to the above since it deals with File Explorer as well. For security reasons, it's smart to always show file extensions. This makes it easier to spot rogue EXE files masquerading as a PDF, or similar. It's also handy when you need to deal with Windows 10 file associations.

The below script will let you toggle showing extensions for known file types with Win + Y.

Download:Toggle Known File Extensions Script

6. Insert Special Characters

Aside from the few special characters on your keyboard (like @ and *), there are dozens more that aren't so convenient to access. One of the fastest ways to input foreign characters and other uncommon symbols is using AutoHotkey.

With just a line of AHK code, you can quickly insert these special symbols and stop having to remember ALT codes, or copying and pasting from an online list.

Use the template below to create shortcuts that are most useful for you. The characters left of the two colons are what you press to trigger the shortcut, while the symbol inside the brackets is what the shortcut inserts.

So for example, if you want to press Alt + Q to insert the trademark icon, you would create a script with this:

For reference, the characters for keys are as follows. You can read more about hotkeys on AutoHotkey's guide page:

  • ^ for Ctrl
  • ! for Alt
  • # for Win
  • + for Shift

7. Run a Quick Google Search

If you're a heavy Google searcher, this handy shortcut lets you run a search for any copied text on your computer.

It will launch your default browser and search Google for any bit of text you have highlighted when you press Ctrl + Shift + C. It's handy to reduce copying and pasting all the time!

8. Use the Numpad as a Mouse

While you can navigate Windows without a mouse if needed, having this script around means you don't have to remember keyboard shortcuts to do this. This neat AutoHotkey script uses your number pad to act as a mouse, giving you more precision and a way to get around your computer in case of hardware failure.

Have a look at the information at the top of the script for guidance on using it.

Download:Using Keyboard Numpad as a Mouse Script

9. Launch Any App

The Start menu makes it easy to pull up any program installed on your computer in seconds. But for your most-used programs, you might want an even faster way to launch them.

The script to open an app is simple; here's one to launch Firefox when you press Win + F. Change it as needed for your preferred key combo and app.

10. Makeshift Volume Keys

Most keyboards have keys to easily change the volume, change the music track, and similar. But in case yours doesn't have these, you can use AutoHotkey to come up with your own volume buttons.

Here's one example, which uses Shift + Plus and Shift + Minus (keys on the number pad) to raise and lower the volume. You can also hit the little-used Break key to toggle mute.

As with the other scripts, feel free to adjust the buttons to your liking.

Writing Your Own Scripts

If you feel confident, why not try making your own AutoHotkey scripts next? If you're just getting started with AHK, you'll probably benefit the most from text expansion.

Read More: Best Text Expansion Tools for Windows

Essentially, text expansion lets you type a small bit of text that automatically expands to something much longer. If you send the same email multiple times per day, or type out your email address all the time when signing into websites, setting up text expansion will make you more productive.

If you downloaded the AutoCorrect script from #1 above, there's a spot at the bottom for you to add any phrases of your own, which is a perfect place to put some single-line expansion. If you're not using this script, just make a new script for your expansion entries.

It's simple to do: type two colons, followed by the hotkey text. After two more colons, type the phrase you want the shortcut to expand to. So if you wanted to make typing "@@" auto-expand to your email address, the script would be:

The possibilities here are many. You could make the hotkey Ctrl + Alt + C spit out a canned email that you type several times a day, or any number of other tasks pertinent to your work:

Once you've set up some text expansion, you can start remapping keys if you find some of them not useful in their current state.

Do you wish the Insert button was instead a shortcut for Copy, for example? You can change that with the following:

Check out the AutoHotkey tutorials for more info. For a more guided introduction to AHK, we have an AutoHotkey guide for beginners you can also check out.

The Power of AutoHotkey

The great part about AutoHotkey is that it's completely customizable for your needs. If you just want auto-correction and a few simple bits of text expansion, you can easily set that up. If you want to go deeper with lots of custom controls and complex shortcuts, you can write any scripts you please.

With these great AutoHotkey scripts, you don't need any coding experience to get started. For a similar tool, you should also look into the basics of Windows batch files.

Image Credit: FabrikaSimf/Shutterstock


How to Use Windows Batch File Commands to Automate Repetitive Tasks

Do you frequently execute boring and repetitive tasks? A batch file might be exactly what you’re looking for. Use it to automate actions. We'll show you the commands you need to know.

Read Next

About The Author
Ben Stegner (1772 Articles Published)

Ben is a Deputy Editor and the Onboarding Manager at MakeUseOf. He left his IT job to write full-time in 2016 and has never looked back. He's been covering tech tutorials, video game recommendations, and more as a professional writer for over seven years.

More From Ben Stegner

Subscribe to our newsletter

Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!

Click here to subscribe


How To Get a Send Script to Enter a '#' Symbol?

Hello -

I am have written a very simple SEND script which includes the '#' symbol. The problem is the '#' symbol is followed by the letter 'L'. To AutoHotKey the '#' symbol means the Windows Key. So, when I launch this script it actually locks my computer. This is kinda cool, but not quite what I intended.

Is there a way to tell AutoHotKey that the '#' symbol in this case does not mean the Windows Key - that it literally means I want the '#' symbol typed out in the output?

The answer to this may be in the forum or articles, but I didn't have time to scour them very thoroughly and just thought I'd throw this out there in case someone happens to know the answer.

Here is a copy of the code:

^!v:: Send #L
Thanks for any and all suggestions.
#1 - Posted 27 February 2009 - 11:43 PM
  1. Super soul sunday dvd
  2. Amazon armless desk chair
  3. Mint condition songs
  4. Mr horsepower drawing

Send, SendRaw, SendInput, SendPlay, SendEvent

Sends simulated keystrokes and mouse clicks to the active window.

Send Keys SendRaw Keys SendInput Keys SendPlay Keys SendEvent Keys



The sequence of keys to send. As with other commands, the comma in front of the first parameter is optional.

By default (that is, if neither SendRaw nor the Raw mode or Text mode is used), the characters have a special meaning. The characters represent the modifier keys , , and . They affect only the very next key. To send the corresponding modifier key on its own, enclose the key name in braces. To just press (hold down) or release the key, follow the key name with the word "down" or "up" as shown below.

^{Ctrl}{Ctrl down}{Ctrl up} presses +
+{Shift}{Shift down}{Shift up} sends the text "AbC"
presses ++
!{Alt}{Alt down}{Alt up} presses +
{LWin down}
{RWin down}
{LWin up}
{RWin up}
holds down and then presses

Note: As capital letters are produced by sending , produces a different effect in some programs than . For example, presses ++ and presses +. If in doubt, use lowercase.

The characters are used to enclose key names and other options, and to send special characters literally. For example, is and is a literal exclamation mark.

[v1.1.27+]: Enclosing a plain ASCII letter (a-z or A-Z) in braces forces it to be sent as the corresponding virtual keycode, even if the character does not exist on the current keyboard layout. In other words, produces the letter "a" while may or may not produce "a", depending on the keyboard layout. For details, see the remarks below.

Send variants

Send: By default, Send is synonymous with SendEvent; but it can be made a synonym for SendInput or SendPlay via SendMode.

SendRaw: Similar to Send, except that all characters in Keys are interpreted and sent literally. See Raw mode for details.

SendInput and SendPlay[v1.0.43+]: SendInput and SendPlay use the same syntax as Send but are generally faster and more reliable. In addition, they buffer any physical keyboard or mouse activity during the send, which prevents the user's keystrokes from being interspersed with those being sent. SendMode can be used to make Send synonymous with SendInput or SendPlay. For more details about each mode, see SendInput and SendPlay below.

SendEvent[v1.0.43+]: SendEvent sends keystrokes using the same method as the pre-1.0.43 Send command. The rate at which keystrokes are sent is determined by SetKeyDelay.

Special modes

The following modes affect the interpretation of the characters in Keys or the behavior of key-sending commands such as Send, SendInput, SendPlay, SendEvent and ControlSend. These modes must be specified as in Keys, where x is either Raw, Text, or Blind. For example, .

Raw mode

The Raw mode can be either enabled with , SendRaw or ControlSendRaw, which causes all subsequent characters, including the special characters , to be interpreted literally rather than translating to , to +, etc. For example, both and send instead of .

The Raw mode does not affect the interpretation of escape sequences, variable references and expressions. For example, sends the string . When using ControlSend, it is also necessary to escape literal commas ().

Text mode [v1.1.27+]

The Text mode can be enabled with , which is similar to the Raw mode, except that no attempt is made to translate characters (other than , , and ) to keycodes; instead, the fallback method is used for all of the remaining characters. For SendEvent, SendInput and ControlSend, this improves reliability because the characters are much less dependent on correct modifier state. This mode can be combined with the Blind mode to avoid releasing any modifier keys: . However, some applications require that the modifier keys be released.

, and are all translated to a single , unlike the default behavior and Raw mode, which translate to two . is translated to and to , but all other characters are sent without translation.

[v1.1.29+]: Like the Blind mode, the Text mode ignores SetStoreCapsLockMode (that is, the state of is not changed) and does not wait for to be released. This is because the Text mode typically does not depend on the state of and cannot trigger the system + hotkey. However, this only applies when Keys begins with or .

Blind mode

The Blind mode can be enabled with , which gives the script more control by disabling a number of things that are normally done automatically to make things work as expected. must be the first item in the string to enable the Blind mode. It has the following effects:

  • The Blind mode avoids releasing the modifier keys (Alt, Ctrl, Shift, and Win) if they started out in the down position. For example, the hotkey would send ABC rather than abc because the user is holding down .
  • Modifier keys are restored differently to allow a Send to turn off a hotkey's modifiers even if the user is still physically holding them down. For example, automatically pushes back down if the user is still physically holding , whereas allows to be logically up even though it is physically down.
  • SetStoreCapsLockMode is ignored; that is, the state of is not changed.
  • Menu masking is disabled. That is, Send omits the extra keystrokes that would otherwise be sent in order to prevent: 1) Start Menu appearance during Win keystrokes (LWin/RWin); 2) menu bar activation during Alt keystrokes. However, the Blind mode does not prevent masking performed by the keyboard hook following activation of a hook hotkey.
  • Send does not wait for to be released even if the text contains an keystroke. This would normally be done to prevent Send from triggering the system "lock workstation" hotkey (+). See Hotkeys for details.

The Blind mode is used internally when remapping a key. For example, the remapping would produce: 1) "b" when you type "a"; 2) uppercase "B" when you type uppercase "A"; and 3) + when you type +.

is not supported by SendRaw or ControlSendRaw; use instead.

The Blind mode is not completely supported by SendPlay, especially when dealing with the modifier keys (Ctrl, Alt, Shift, and Win).

Key names

The following table lists the special keys that can be sent (each key name must be enclosed in braces):

Key nameDescription
{F1} - {F24}Function keys. For example: {F12} is .
{Enter} on the main keyboard
{Escape} or {Esc}
{Space} (this is only needed for spaces that appear either at the beginning or the end of the string to be sent -- ones in the middle can be literal spaces)
{Backspace} or {BS}
{Delete} or {Del}
{Insert} or {Ins}
{Up} (up arrow) on main keyboard
{Down} (down arrow) on main keyboard
{Left} (left arrow) on main keyboard
{Right} (right arrow) on main keyboard
{Home} on main keyboard
{End} on main keyboard
{PgUp} on main keyboard
{PgDn} on main keyboard
{CapsLock} (using SetCapsLockState is more reliable on Win 2k/XP). Sending {CapsLock} might require beforehand.
{ScrollLock} (see also: SetScrollLockState)
{NumLock} (see also: SetNumLockState)
{Control} or {Ctrl} (technical info: sends the neutral virtual key but the left scan code)
{LControl} or {LCtrl}Left (technical info: sends the left virtual key rather than the neutral one)
{RControl} or {RCtrl}Right
{Control down} or {Ctrl down}Holds down until {Ctrl up} is sent. To hold down the left or right key instead, use {RCtrl down} and {RCtrl up}.
{Alt} (technical info: sends the neutral virtual key but the left scan code)
{LAlt}Left (technical info: sends the left virtual key rather than the neutral one)
{RAlt}Right (or , depending on keyboard layout)
{Alt down}Holds down until {Alt up} is sent. To hold down the left or right key instead, use {RAlt down} and {RAlt up}.
{Shift} (technical info: sends the neutral virtual key but the left scan code)
{LShift}Left (technical info: sends the left virtual key rather than the neutral one)
{Shift down}Holds down until {Shift up} is sent. To hold down the left or right key instead, use {RShift down} and {RShift up}.
{LWin down}Holds the left down until {LWin up} is sent
{RWin down}Holds the right down until {RWin up} is sent
{AppsKey} (invokes the right-click or context menu)
{ASC nnnnn}

Sends an +nnnnn keypad combination, which can be used to generate special characters that don't exist on the keyboard. To generate ASCII characters, specify a number between 1 and 255. To generate ANSI characters (standard in most languages), specify a number between 128 and 255, but precede it with a leading zero, e.g. {Asc 0133}.

Unicode characters may be generated by specifying a number between 256 and 65535 (without a leading zero). However, this is not supported by all applications. For alternatives, see the section below.


[AHK_L 24+]: Sends a Unicode character where nnnn is the hexadecimal value of the character excluding the 0x prefix. This typically isn't needed in Unicode versions of AutoHotkey, where Send and ControlSend automatically support Unicode text.

SendInput() or WM_CHAR is used to send the character and the current Send mode has no effect. Characters sent this way usually do not trigger shortcut keys or hotkeys.


Sends a keystroke that has virtual key XX and scan code YYY. For example: . If the sc or vk portion is omitted, the most appropriate value is sent in its place.

The values for XX and YYY are hexadecimal and can usually be determined from the main window's View->Key history menu item. See also: Special Keys

Warning: Combining vk and sc in this manner is valid only with Send. Prior to [v1.1.27], hotkeys permitted but ignored any non-hexadecimal characters following XX.

{Numpad0} - {Numpad9}Numpad digit keys (as seen when is ON). For example: {Numpad5} is .
{NumpadDot} (numpad period) (as seen when is ON).
{NumpadEnter} on keypad
{NumpadMult} (numpad multiplication)
{NumpadDiv} (numpad division)
{NumpadAdd} (numpad addition)
{NumpadSub} (numpad subtraction)
{NumpadDel} on keypad (this key and the following Numpad keys are used when is OFF)
{NumpadIns} on keypad
{NumpadClear}Clear key on keypad (usually when is OFF).
{NumpadUp} (up arrow) on keypad
{NumpadDown} (down arrow) on keypad
{NumpadLeft} (left arrow) on keypad
{NumpadRight} (right arrow) on keypad
{NumpadHome} on keypad
{NumpadEnd} on keypad
{NumpadPgUp} on keypad
{NumpadPgDn} on keypad
{Browser_Back}Select the browser "back" button
{Browser_Forward}Select the browser "forward" button
{Browser_Refresh}Select the browser "refresh" button
{Browser_Stop}Select the browser "stop" button
{Browser_Search}Select the browser "search" button
{Browser_Favorites}Select the browser "favorites" button
{Browser_Home}Launch the browser and go to the home page
{Volume_Mute}Mute/unmute the master volume. Usually equivalent to .
{Volume_Down}Reduce the master volume. Usually equivalent to .
{Volume_Up}Increase the master volume. Usually equivalent to .
{Media_Next}Select next track in media player
{Media_Prev}Select previous track in media player
{Media_Stop}Stop media player
{Media_Play_Pause}Play/pause media player
{Launch_Mail}Launch the email application
{Launch_Media}Launch media player
{Launch_App1}Launch user app1
{Launch_App2}Launch user app2
{Click [Options]}
Sends a mouse click using the same options available in the Click command. For example, would click the left mouse button once at the mouse cursor's current position, and would click at coordinates 100, 200 (based on CoordMode). To move the mouse without clicking, specify 0 after the coordinates; for example: . The delay between mouse clicks is determined by SetMouseDelay (not SetKeyDelay).
{WheelDown}, {WheelUp}, {WheelLeft}, {WheelRight}, {LButton}, {RButton}, {MButton}, {XButton1}, {XButton2}

Sends a mouse button event at the cursor's current position (to have control over position and other options, use {Click} above). The delay between mouse clicks is determined by SetMouseDelay. WheelLeft/Right require [v1.0.48+], but have no effect on operating systems older than Windows Vista.

LButton and RButton correspond to the "physical" left and right buttons when used with Send, but the "logical" left and right buttons when used with hotkeys. In other words, if the user has swapped the buttons via system settings, performs a logical right click, but a physical left click activates the hotkey. Likewise for and . To always perform a logical click, use {Click} instead.

{Blind}Enables the Blind mode, which gives the script more control by disabling a number of things that are normally done automatically to make things generally work as expected. The string must occur at the beginning of the string.
Enables the Raw mode, which causes the following characters to be interpreted literally: . Although the string need not occur at the beginning of the string, once specified, it stays in effect for the remainder of the string.
Enables the Text mode, which sends a stream of characters rather than keystrokes. Like the Raw mode, the Text mode causes the following characters to be interpreted literally: . Although the string need not occur at the beginning of the string, once specified, it stays in effect for the remainder of the string.

Repeating or Holding Down a Key

To repeat a keystroke: Enclose in braces the name of the key followed by the number of times to repeat it. For example:

Send {DEL 4} ; Presses the Delete key 4 times. Send {S 30} ; Sends 30 uppercase S characters. Send +{TAB 4} ; Presses Shift-Tab 4 times.

To hold down or release a key: Enclose in braces the name of the key followed by the word Down or Up. For example:

Send {b down}{b up} Send {TAB down}{TAB up} Send {Up down} ; Press down the up-arrow key. Sleep 1000 ; Keep it down for one second. Send {Up up} ; Release the up-arrow key.

When a key is held down via the method above, it does not begin auto-repeating like it would if you were physically holding it down (this is because auto-repeat is a driver/hardware feature). However, a Loop can be used to simulate auto-repeat. The following example sends 20 tab keystrokes:

Loop 20 { Send {Tab down} ; Auto-repeat consists of consecutive down-events (with no up-events). Sleep 30 ; The number of milliseconds between keystrokes (or use SetKeyDelay). } Send {Tab up} ; Release the key.

By default, Send will not automatically release a modifier key (Control, Shift, Alt, and Win) if that modifier key was "pressed down" by sending it. For example, may behave similar to if the user is physically holding , but followed by will produce +. DownTemp and DownR can be used to override this behavior. DownTemp and DownR have the same effect as Down except for the modifier keys (Control, Shift, Alt, and Win).

DownTemp tells subsequent sends that the key is not permanently down, and may be released whenever a keystroke calls for it. For example, followed later by would produce , not +. Any use of Send may potentially release the modifier permanently, so DownTemp is not ideal for remapping modifier keys.

[v1.1.27+]:DownR (where "R" stands for remapping, which is its main use) tells subsequent sends that if the key is automatically released, it should be pressed down again when send is finished. For example, followed later by would produce , not +, but will leave in the pressed state for use with keyboard shortcuts. In other words, DownR has an effect similar to physically pressing the key.

If a character does not correspond to a virtual key on the current keyboard layout, it cannot be "pressed" or "released". For example, has no effect on most layouts, and is equivalent to .

Characters vs. keys: By default, characters are sent by first translating them to keystrokes. If this translation is not possible (that is, if the current keyboard layout does not contain a key or key combination which produces that character), the character is sent by one of following fallback methods:

  • SendEvent and SendInput use SendInput() with the KEYEVENTF_UNICODE flag. [v1.1.27+]: ANSI builds of AutoHotkey convert the character to Unicode before sending it. Prior to v1.1.27, ANSI builds used the Alt+nnnnn method.
  • SendPlay uses the Alt+nnnnn method, which produces Unicode only if supported by the target application.
  • ControlSend posts a WM_CHAR message.

Note: Characters sent using any of the above methods usually do not trigger keyboard shortcuts or hotkeys.

[v1.1.27+]: For characters in the range a-z or A-Z (plain ASCII letters), each character which does not exist in the current keyboard layout may be sent either as a character or as the corresponding virtual keycode (vk41-vk5A):

  • If a naked letter is sent (that is, without modifiers or braces), or if Raw mode is in effect, it is sent as a character. For example, sends the expected text, even though pressing (vk52) produces some other character (such as on the Russian layout). can be omitted in this case, unless a modifier key was put into effect by a prior Send.
  • If one or more modifier keys have been put into effect by the Send command, or if the letter is wrapped in braces, it is sent as a keycode (modified with if the letter is upper-case). This allows the script to easily activate standard keyboard shortcuts. For example, and activate the standard + shortcut and is equivalent to .

If the letter exists in the current keyboard layout, it is always sent as whichever keycode the layout associates with that letter (unless the Text mode is used, in which case the character is sent by other means). In other words, the section above is only relevant for non-Latin based layouts such as Russian.

Modifier State: When Send is required to change the state of the or modifier keys (such as if the user was holding one of those keys), it may inject additional keystrokes ( by default) to prevent the Start menu or window menu from appearing. For details, see #MenuMaskKey.

BlockInput Compared to SendInput/SendPlay: Although the BlockInput command can be used to prevent any keystrokes physically typed by the user from disrupting the flow of simulated keystrokes, it is often better to use SendInput or SendPlay so that keystrokes and mouse clicks become uninterruptible. This is because unlike BlockInput, SendInput/Play does not discard what the user types during the send; instead, such keystrokes are buffered and sent afterward.

When sending a large number of keystrokes, a continuation section can be used to improve readability and maintainability.

Since the operating system does not allow simulation of the ++ combination, doing something like will have no effect.

Send may have no effect on Windows Vista or later if the active window is running with administrative privileges and the script is not. This is due to a security mechanism called User Interface Privilege Isolation.

SendInput [v1.0.43+]

SendInput is generally the preferred method to send keystrokes and mouse clicks because of its superior speed and reliability. Under most conditions, SendInput is nearly instantaneous, even when sending long strings. Since SendInput is so fast, it is also more reliable because there is less opportunity for some other window to pop up unexpectedly and intercept the keystrokes. Reliability is further improved by the fact that anything the user types during a SendInput is postponed until afterward.

Unlike the other sending modes, the operating system limits SendInput to about 5000 characters (this may vary depending on the operating system's version and performance settings). Characters and events beyond this limit are not sent.

Note: SendInput ignores SetKeyDelay because the operating system does not support a delay in this mode. However, when SendInput reverts to SendEvent under the conditions described below, it uses (unless SendEvent's KeyDelay is , in which case is used). When SendInput reverts to SendPlay, it uses SendPlay's KeyDelay.

If a script other than the one executing SendInput has a low-level keyboard hook installed, SendInput automatically reverts to SendEvent (or SendPlay if is in effect). This is done because the presence of an external hook disables all of SendInput's advantages, making it inferior to both SendPlay and SendEvent. However, since SendInput is unable to detect a low-level hook in programs other than [AutoHotkey v1.0.43+], it will not revert in these cases, making it less reliable than SendPlay/Event.

When SendInput sends mouse clicks by means such as {Click}, and is in effect (the default), every click will be relative to the window that was active at the start of the send. Therefore, if SendInput intentionally activates another window (by means such as alt-tab), the coordinates of subsequent clicks within the same command will be wrong because they will still be relative to the old window rather than the new one.

SendPlay [v1.0.43+]

Warning: SendPlay may have no effect at all if UAC is enabled, even if the script is running as an administrator. For more information, refer to the FAQ.

SendPlay's biggest advantage is its ability to "play back" keystrokes and mouse clicks in a broader variety of games than the other modes. For example, a particular game may accept hotstrings only when they have the SendPlay option.

Of the three sending modes, SendPlay is the most unusual because it does not simulate keystrokes and mouse clicks per se. Instead, it creates a series of events (messages) that flow directly to the active window (similar to ControlSend, but at a lower level). Consequently, SendPlay does not trigger hotkeys or hotstrings.

Like SendInput, SendPlay's keystrokes do not get interspersed with keystrokes typed by the user. Thus, if the user happens to type something during a SendPlay, those keystrokes are postponed until afterward.

Although SendPlay is considerably slower than SendInput, it is usually faster than the traditional SendEvent mode (even when KeyDelay is -1).

Both (LWin and RWin) are automatically blocked during a SendPlay if the keyboard hook is installed. This prevents the Start Menu from appearing if the user accidentally presses during the send. By contrast, keys other than LWin and RWin do not need to be blocked because the operating system automatically postpones them until after the SendPlay (via buffering).

SendPlay does not use the standard settings of SetKeyDelay and SetMouseDelay. Instead, it defaults to no delay at all, which can be changed as shown in the following examples:

SetKeyDelay, 0, 10, Play; Note that both 0 and -1 are the same in SendPlay mode.SetMouseDelay, 10, Play

SendPlay is unable to turn on or off , , or . Similarly, it is unable to change a key's state as seen by GetKeyState() unless the keystrokes are sent to one of the script's own windows. Even then, any changes to the left/right modifier keys (e.g. RControl) can be detected only via their neutral counterparts (e.g. Control). Also, SendPlay has other limitations described on the SendMode page.

Unlike SendInput and SendEvent, the user may interrupt a SendPlay by pressing ++ or +. When this happens, the remaining keystrokes are not sent but the script continues executing as though the SendPlay had completed normally.

Although SendPlay can send LWin and RWin events, they are sent directly to the active window rather than performing their native operating system function. To work around this, use SendEvent. For example, would show the Start Menu's Run dialog.


SendMode, SetKeyDelay, SetStoreCapsLockMode, Escape sequences (e.g. `%), ControlSend, BlockInput, Hotstrings, WinActivate


Types a two-line signature.

Send Sincerely,{enter}John Smith

Selects the File->Save menu (Alt+F followed by S).

Send !fs

Jumps to the end of the text then send four shift+left-arrow keystrokes.

Send {End}+{Left 4}

Sends a long series of raw characters via the fastest method.

SendInput {Raw}A long series of raw characters sent via the fastest method.

List of Keys (Keyboard, Mouse and Joystick)

Table of Contents


General Buttons

LButtonThe left mouse button when used with Send, but the primary mouse button when used with hotkeys. In other words, if the user has swapped the buttons via system settings, is physically activated by clicking the right mouse button, but performs the same as physically clicking the left button. To always perform a logical left click, use or .
RButtonThe right mouse button when used with Send, but the secondary mouse button when used with hotkeys. In other words, if the user has swapped the buttons via system settings, is physically activated by clicking the left mouse button, but performs the same as physically clicking the right button. To always perform a logical right click, use or .
MButtonMiddle or wheel mouse button

Advanced Buttons

XButton14th mouse button. Typically performs the same function as Browser_Back.
XButton25th mouse button. Typically performs the same function as Browser_Forward.


WheelDownTurn the wheel downward (toward you).
WheelUpTurn the wheel upward (away from you).

[v1.0.48+]: Scroll to the left or right.

Requires Windows Vista or later. These can be used as hotkeys with some (but not all) mice which have a second wheel or support tilting the wheel to either side. In some cases, software bundled with the mouse must instead be used to control this feature. Regardless of the particular mouse, Send and Click can be used to scroll horizontally in programs which support it.


Note: The names of the letter and number keys are the same as that single letter or digit. For example: b is and 5 is .

Although any single character can be used as a key name, its meaning (scan code or virtual keycode) depends on the current keyboard layout. Additionally, some special characters may need to be escaped or enclosed in braces, depending on the context. [v1.1.27+]: The letters a-z or A-Z can be used to refer to the corresponding virtual keycodes (usually vk41-vk5A) even if they are not included in the current keyboard layout.

General Keys

CapsLock (caps lock key)

Note: Windows IME may interfere with the detection and functionality of CapsLock; see CapsLock and IME for details.

Space (space bar)
Tab (tabulator key)
ReturnDeprecated: Use the synonym instead to reduce ambiguity.
Escape (or Esc)
Backspace (or BS)

Cursor Control Keys

ScrollLock (scroll lock key). While is held down, produces the key code of , but can be differentiated from by scan code.
Delete (or Del)
Insert (or Ins)
PgUp (page up key)
PgDn (page down key)
Up (up arrow key)
Down (down arrow key)
Left (left arrow key)
Right (right arrow key)

Numpad Keys

Due to system behavior, the following keys separated by a slash are identified differently depending on whether is ON or OFF. If is OFF but is pressed, the system temporarily releases and acts as though is ON.

Numpad0 / NumpadIns /
Numpad1 / NumpadEnd /
Numpad2 / NumpadDown /
Numpad3 / NumpadPgDn /
Numpad4 / NumpadLeft /
Numpad5 / NumpadClear / typically does nothing
Numpad6 / NumpadRight /
Numpad7 / NumpadHome /
Numpad8 / NumpadUp /
Numpad9 / NumpadPgUp /
NumpadDot / NumpadDel /
NumLock (number lock key). While is held down, produces the key code of , so use in hotkeys instead of .
NumpadDiv (division)
NumpadMult (multiplication)
NumpadAdd (addition)
NumpadSub (subtraction)

Function Keys

F1 - F24The 12 or more function keys at the top of most keyboards.

Modifier Keys

LWinLeft . Corresponds to the hotkey prefix.

Right . Corresponds to the hotkey prefix.

Note: Unlike //, there is no generic/neutral "Win" key because the OS does not support it. However, hotkeys with the modifier can be triggered by either .

Control (or Ctrl). As a hotkey () it fires upon release unless it has the tilde prefix. Corresponds to the hotkey prefix.
Alt. As a hotkey () it fires upon release unless it has the tilde prefix. Corresponds to the hotkey prefix.
Shift. As a hotkey () it fires upon release unless it has the tilde prefix. Corresponds to the hotkey prefix.
LControl (or LCtrl)Left . Corresponds to the hotkey prefix.
RControl (or RCtrl)Right . Corresponds to the hotkey prefix.
LShiftLeft . Corresponds to the hotkey prefix.
RShiftRight . Corresponds to the hotkey prefix.
LAltLeft . Corresponds to the hotkey prefix.

Right . Corresponds to the hotkey prefix.

Note: If your keyboard layout has AltGr instead of RAlt, you can probably use it as a hotkey prefix via as described here. In addition, would make AltGr itself into a hotkey.

Multimedia Keys

The function assigned to each of the keys listed below can be overridden by modifying the Windows registry. This table shows the default function of each key on most versions of Windows.

Volume_MuteMute the volume
Volume_DownLower the volume
Volume_UpIncrease the volume
Media_NextNext Track
Media_PrevPrevious Track
Launch_MailLaunch default e-mail program
Launch_MediaLaunch default media player
Launch_App1Launch My Computer
Launch_App2Launch Calculator

Other Keys

AppsKey. This is the key that invokes the right-click context menu.
PrintScreen (print screen key)
CtrlBreak+ or +
Pause or +. While is held down, produces the key code of and produces , so use in hotkeys instead of .
BreakDeprecated: Use the synonym instead.
Help. This probably doesn't exist on most keyboards. It's usually not the same as .
Sleep. Note that the sleep key on some keyboards might not work with this.
SCnnnSpecify for nnn the scan code of a key. Recognizes unusual keys not mentioned above. See Special Keys for details.

Specify for nn the hexadecimal virtual key code of a key. This rarely-used method also prevents certain types of hotkeys from requiring the keyboard hook. For example, the following hotkey does not use the keyboard hook, but as a side-effect it is triggered by pressing either or NumpadHome:

^VK24::MsgBox You pressed Home or NumpadHome while holding down Control.

Known limitation: VK hotkeys that are forced to use the keyboard hook, such as or , will fire for only one of the keys, not both (e.g. NumpadHome but not ). For more information about the VKnn method, see Special Keys.

Warning: Only Send, GetKeyName(), GetKeyVK(), GetKeySC() and #MenuMaskKey support combining VKnn and SCnnn. [v1.1.27+]: The presence of an invalid suffix prevents VKnn from being recognized. For example, raises an error in v1.1.27+, but was ignored (had no effect) in previous versions.


Joy1 through Joy32: The buttons of the joystick. To help determine the button numbers for your joystick, use this test script. Note that hotkey prefix symbols such as ^ (control) and + (shift) are not supported (though GetKeyState() can be used as a substitute). Also note that the pressing of joystick buttons always "passes through" to the active window if that window is designed to detect the pressing of joystick buttons.

Although the following Joystick control names cannot be used as hotkeys, they can be used with GetKeyState():

  • JoyX, JoyY, and JoyZ: The X (horizontal), Y (vertical), and Z (altitude/depth) axes of the joystick.
  • JoyR: The rudder or 4th axis of the joystick.
  • JoyU and JoyV: The 5th and 6th axes of the joystick.
  • JoyPOV: The point-of-view (hat) control.
  • JoyName: The name of the joystick or its driver.
  • JoyButtons: The number of buttons supported by the joystick (not always accurate).
  • JoyAxes: The number of axes supported by the joystick.
  • JoyInfo: Provides a string consisting of zero or more of the following letters to indicate the joystick's capabilities: Z (has Z axis), R (has R axis), U (has U axis), V (has V axis), P (has POV control), D (the POV control has a limited number of discrete/distinct settings), C (the POV control is continuous/fine). Example string: ZRUVPD

Multiple Joysticks: If the computer has more than one joystick and you want to use one beyond the first, include the joystick number (max 16) in front of the control name. For example, 2joy1 is the second joystick's first button.

Note: If you have trouble getting a script to recognize your joystick, one person reported needing to specify a joystick number other than 1 even though only a single joystick was present. It is unclear how this situation arises or whether it is normal, but experimenting with the joystick number in the joystick test script can help determine if this applies to your system.

See Also:

Hand-held Remote Controls

Respond to signals from hand-held remote controls via the WinLIRC client script.

Special Keys

If your keyboard or mouse has a key not listed above, you might still be able to make it a hotkey by using the following steps:

  1. Ensure that at least one script is running that is using the keyboard hook. You can tell if a script has the keyboard hook by opening its main window and selecting "View->Key history" from the menu bar.
  2. Double-click that script's tray icon to open its main window.
  3. Press one of the "mystery keys" on your keyboard.
  4. Select the menu item "View->Key history"
  5. Scroll down to the bottom of the page. Somewhere near the bottom are the key-down and key-up events for your key. NOTE: Some keys do not generate events and thus will not be visible here. If this is the case, you cannot directly make that particular key a hotkey because your keyboard driver or hardware handles it at a level too low for AutoHotkey to access. For possible solutions, see further below.
  6. If your key is detectable, make a note of the 3-digit hexadecimal value in the second column of the list (e.g. 159).
  7. To define this key as a hotkey, follow this example: SC159::; Replace 159 with your key's value. MsgBox, %A_ThisHotkey% was pressed. return

Reverse direction: To remap some other key to become a "mystery key", follow this example:

; Replace 159 with the value discovered above. Replace FF (if needed) with the ; key's virtual key, which can be discovered in the first column of the Key History screen. #c::Send {vkFFsc159} ; See Send {vkXXscYYY} for more details.

Alternate solutions: If your key or mouse button is not detectable by the Key History screen, one of the following might help:

  1. Reconfigure the software that came with your mouse or keyboard (sometimes accessible in the Control Panel or Start Menu) to have the "mystery key" send some other keystroke. Such a keystroke can then be defined as a hotkey in a script. For example, if you configure a mystery key to send +, you can then indirectly make that key as a hotkey by using in a script.

  2. Try AHKHID. You can also try searching the forum for a keywords like , or .

  3. The following is a last resort and generally should be attempted only in desperation. This is because the chance of success is low and it may cause unwanted side-effects that are difficult to undo:
    Disable or remove any extra software that came with your keyboard or mouse or change its driver to a more standard one such as the one built into the OS. This assumes there is such a driver for your particular keyboard or mouse and that you can live without the features provided by its custom driver and software.

CapsLock and IME

Some configurations of Windows IME (such as Japanese input with English keyboard) use CapsLock to toggle between modes. In such cases, CapsLock is suppressed by the IME and cannot be detected by AutoHotkey. However, the +, + and + shortcuts can be disabled with a workaround. Specifically, send a key-up to modify the state of the IME, but prevent any other effects by signalling the keyboard hook to suppress the event. The following function can be used for this purpose:

; Requires AutoHotkey v1.1.26+, and the keyboard hook must be installed. #InstallKeybdHook SendSuppressedKeyUp(key) { DllCall("keybd_event" , "char", GetKeyVK(key) , "char", GetKeySC(key) , "uint", KEYEVENTF_KEYUP := 0x2 , "uptr", KEY_BLOCK_THIS := 0xFFC3D450) }

After copying the function into a script or saving it as SendSuppressedKeyUp.ahk in a function library, it can be used as follows:

; Disable Alt+key shortcuts for the IME. ~LAlt::SendSuppressedKeyUp("LAlt") ; Test hotkey: !CapsLock::MsgBox % A_ThisHotkey ; Remap CapsLock to LCtrl in a way compatible with IME. *CapsLock:: Send {Blind}{LCtrl DownR} SendSuppressedKeyUp("LCtrl") return *CapsLock up:: Send {Blind}{LCtrl Up} return

Symbols autohotkey

Adding symbols to keys in Windows 7 (involving Alt Gr and FN combos)

Postby krs000aaa » Fri Jan 05, 2018 9:36 am


I don't know exactly how to ask the question (I'm quite terrible with computers), so I will just describe exactly what I want to do, and I hope someone can give me some advice on how to do this.

1. In the upper left corner of my keyboard, right below the ESC key, there is a key called §, and the same key can also type ½ if pressed while holding SHIFT. I want to somehow customize this key, so while holding the FN key and pressing the key, the vertical bar symbol | will be typed.

2. I also want to add the bracket symbols < and > to two of the regular alphabetical keys on my keyboard, and I want these bracket symbols accessed when pushing the said keys while holding ALT GR.

Is there any easy way to do this with AutoHotKey? Like I said, I'm not very good with this stuff. I tried a software called SharpKeys, but I don't understand it at all. Furthermore, someone told me what I want to do is not possible in that software anyways, and instead suggested I should try AutoHotKey. I looked at some of the AutoHotKey tutorials but it seems very complex (to someone like me anyway). Can someone tell me if what I'm asking is even possible to do with AutoHotKey, and if it is, would anyone be willing to guide me step by step on how to do it?

Any help appreciated!!



Hotkeys (Mouse, Joystick and Keyboard Shortcuts)

Table of Contents

Introduction and Simple Examples

Hotkeys are sometimes referred to as shortcut keys because of their ability to easily trigger an action (such as launching a program or keyboard macro). In the following example, the hotkey + is configured to launch Notepad. The pound sign [#] stands for , which is known as a modifier key:

#n:: Run Notepad return

In the final line above, serves to finish the hotkey. However, if a hotkey needs to execute only a single line, that line can be listed to the right of the double-colon. In other words, the is implicit:

#n::Run Notepad

To use more than one modifier with a hotkey, list them consecutively (the order does not matter). The following example uses to indicate ++:

^!s:: Send Sincerely,{enter}John Smith ; This line sends keystrokes to the active (foremost) window. return

Hotkey Modifier Symbols

You can use the following modifier symbols to define hotkeys:


(Windows logo key).

[v1.0.48.01+]: For Windows Vista and later, hotkeys that include (e.g. #a) will wait for to be released before sending any text containing an keystroke. This prevents usages of Send within such a hotkey from locking the PC. This behavior applies to all sending modes except SendPlay (which doesn't need it) and blind mode. [v1.1.29+]:Text mode is also excluded.

Note: Pressing a hotkey which includes may result in extra simulated keystrokes ( by default). See #MenuMaskKey.


Note: Pressing a hotkey which includes may result in extra simulated keystrokes ( by default). See #MenuMaskKey.

&An ampersand may be used between any two keys or mouse buttons to combine them into a custom hotkey. See below for details.
<Use the left key of the pair. e.g. <!a is the same as !a except that only the left will trigger it.
>Use the right key of the pair.

(alternate graph, or alternate graphic). If your keyboard layout has instead of a right key, this series of symbols can usually be used to stand for . For example:

<^>!m::MsgBox You pressed AltGr+m. <^<!m::MsgBox You pressed LeftControl+LeftAlt+m.

Alternatively, to make itself into a hotkey, use the following hotkey (without any hotkeys like the above present):

LControl & RAlt::MsgBox You pressed AltGr itself.

Wildcard: Fire the hotkey even if extra modifiers are being held down. This is often used in conjunction with remapping keys or buttons. For example:

*#c::Run Calc.exe ; Win+C, Shift+Win+C, Ctrl+Win+C, etc. will all trigger this hotkey. *ScrollLock::Run Notepad ; Pressing ScrollLock will trigger this hotkey even when modifier key(s) are down.

Wildcard hotkeys always use the keyboard hook, as do any hotkeys eclipsed by a wildcard hotkey. For example, the presence of would cause to always use the hook.


When the hotkey fires, its key's native function will not be blocked (hidden from the system). In both of the below examples, the user's click of the mouse button will be sent to the active window:

~RButton::MsgBox You clicked the right mouse button. ~RButton & C::MsgBox You pressed C while holding down the right mouse button.

Unlike the other prefix symbols, the tilde prefix is allowed to be present on some of a hotkey's variants but absent on others. However, if a tilde is applied to the prefix key of any custom combination which has not been turned off or suspended, it affects the behavior of that prefix key for all combinations.

Special hotkeys that are substitutes for alt-tab always ignore the tilde prefix.

[v1.1.14+]: If the tilde prefix is applied to a custom modifier key (prefix key) which is also used as its own hotkey, that hotkey will fire when the key is pressed instead of being delayed until the key is released. For example, the ~RButton hotkey above is fired as soon as the button is pressed. Prior to [v1.1.14] (or without the tilde prefix), it was fired when the button was released, but only if the RButton & C combination was not activated.

If the tilde prefix is applied only to the custom combination and not the non-combination hotkey, the key's native function will still be blocked. For example, in the script below, holding will show the tooltip and will not trigger a context menu:

AppsKey::ToolTip Press < or > to cycle through windows. AppsKey Up::ToolTip ~AppsKey & <::Send !+{Esc} ~AppsKey & >::Send !{Esc}

If at least one variant of a keyboard hotkey has the tilde modifier, that hotkey always uses the keyboard hook.


This is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise cause it to trigger itself. The $ prefix forces the keyboard hook to be used to implement this hotkey, which as a side-effect prevents the Send command from triggering it. The $ prefix is equivalent to having specified somewhere above the definition of this hotkey.

The $ prefix has no effect for mouse hotkeys, since they always use the mouse hook. It also has no effect for hotkeys which already require the keyboard hook, including any keyboard hotkeys with the tilde (~) or wildcard (*) modifiers, key-up hotkeys and custom combinations. To determine whether a particular hotkey uses the keyboard hook, use ListHotkeys.

[v1.1.06+]:#InputLevel and SendLevel provide additional control over which hotkeys and hotstrings are triggered by the Send command.


The word UP may follow the name of a hotkey to cause the hotkey to fire upon release of the key rather than when the key is pressed down. The following example remaps the left to become the left :

*LWin::Send {LControl down} *LWin Up::Send {LControl up}

"Up" can also be used with normal hotkeys as in this example: . It also works with combination hotkeys (e.g. )

Limitations: 1) "Up" does not work with joystick buttons; and 2) An "Up" hotkey without a normal/down counterpart hotkey will completely take over that key to prevent it from getting stuck down. One way to prevent this is to add a tilde prefix (e.g. )

"Up" hotkeys and their key-down counterparts (if any) always use the keyboard hook.

On a related note, a technique similar to the above is to make a hotkey into a prefix key. The advantage is that although the hotkey will fire upon release, it will do so only if you did not press any other key while it was held down. For example:

LControl & F1::return ; Make left-control a prefix by using it in front of "&" at least once. LControl::MsgBox You released LControl without having used it to modify any other key.

Note: See the Key List for a complete list of keyboard keys and mouse/joystick buttons.

Multiple hotkeys can be stacked vertically to have them perform the same action. For example:

^Numpad0:: ^Numpad1:: MsgBox Pressing either Control+Numpad0 or Control+Numpad1 will display this message. return

A key or key-combination can be disabled for the entire system by having it do nothing. The following example disables the right-side :


Context-sensitive Hotkeys

The directives #IfWinActive/Exist and #If can be used to make a hotkey perform a different action (or none at all) depending on a specific condition. For example:

#IfWinActive, ahk_class Notepad ^a::MsgBox You pressed Ctrl-A while Notepad is active. Pressing Ctrl-A in any other window will pass the Ctrl-A keystroke to that window. #c::MsgBox You pressed Win-C while Notepad is active. #IfWinActive #c::MsgBox You pressed Win-C while any window except Notepad is active. #If MouseIsOver("ahk_class Shell_TrayWnd") ; For MouseIsOver, see #If example 1. WheelUp::Send {Volume_Up} ; Wheel over taskbar: increase/decrease volume. WheelDown::Send {Volume_Down} ;

Custom Combinations

You can define a custom combination of two keys (except joystick buttons) by using " & " between them. In the below example, you would hold down Numpad0 then press the second key to trigger the hotkey:

Numpad0 & Numpad1::MsgBox You pressed Numpad1 while holding down Numpad0. Numpad0 & Numpad2::Run Notepad

The prefix key loses its native function: In the above example, Numpad0 becomes a prefix key; but this also causes Numpad0 to lose its original/native function when it is pressed by itself. To avoid this, a script may configure Numpad0 to perform a new action such as one of the following:

Numpad0::WinMaximize A ; Maximize the active/foreground window. Numpad0::Send {Numpad0} ; Make the release of Numpad0 produce a Numpad0 keystroke. See comment below.

Fire on release: The presence of one of the above custom combination hotkeys causes the release of Numpad0 to perform the indicated action, but only if you did not press any other keys while Numpad0 was being held down. [v1.1.14+]: This behaviour can be avoided by applying the tilde prefix to either hotkey.

Modifiers: Unlike a normal hotkey, custom combinations act as though they have the wildcard (*) modifier by default. For example, will activate even if or is held down when and are pressed, whereas would be activated only by + and not ++.

For standard modifier keys, normal hotkeys typically work as well or better than "custom" combinations. For example, is recommended over .

Combinations of three or more keys are not supported. Combinations which your keyboard hardware supports can usually be detected by using #If and GetKeyState(), but the results may be inconsistent. For example:

; Press AppsKey and Alt in any order, then slash (/). #if GetKeyState("AppsKey", "P") Alt & /::MsgBox Hotkey activated. ; If the keys are swapped, Alt must be pressed first (use one at a time): #if GetKeyState("Alt", "P") AppsKey & /::MsgBox Hotkey activated. ; [ & ] & \:: #if GetKeyState("[") && GetKeyState("]") \::MsgBox

Keyboard hook: Custom combinations involving keyboard keys always use the keyboard hook, as do any hotkeys which use the prefix key as a suffix. For example, causes to always use the hook.

Other Features

NumLock, CapsLock, and ScrollLock: These keys may be forced to be "AlwaysOn" or "AlwaysOff". For example: .

Overriding Explorer's hotkeys: Windows' built-in hotkeys such as + (#e) and + (#r) can be individually overridden simply by assigning them to an action in the script. See the override page for details.

Substitutes for Alt-Tab: Hotkeys can provide an alternate means of alt-tabbing. For example, the following two hotkeys allow you to alt-tab with your right hand:

RControl & RShift::AltTab ; Hold down right-control then press right-shift repeatedly to move forward. RControl & Enter::ShiftAltTab ; Without even having to release right-control, press Enter to reverse direction.

For more details, see Alt-Tab.

Mouse Wheel Hotkeys

Hotkeys that fire upon turning the mouse wheel are supported via the key names WheelDown and WheelUp. Here are some examples of mouse wheel hotkeys:

MButton & WheelDown::MsgBox You turned the mouse wheel down while holding down the middle button. ^!WheelUp::MsgBox You rotated the wheel up while holding down Control+Alt.

[v1.0.48+]: WheelLeft and WheelRight are also supported, but have no effect on operating systems older than Windows Vista. Some mice have a single wheel which can be scrolled up and down or tilted left and right. Generally in those cases, WheelLeft or WheelRight signals are sent repeatedly while the wheel is held to one side, to simulate continuous scrolling. This typically causes the hotkeys to execute repeatedly.

[v1.0.43.03+]: The built-in variable A_EventInfo contains the amount by which the wheel was turned, which is typically 1. However, A_EventInfo can be greater or less than 1 under the following circumstances:

  • If the mouse hardware reports distances of less than one notch, A_EventInfo may contain 0;
  • If the wheel is being turned quickly (depending on type of mouse), A_EventInfo may be greater than 1. A hotkey like the following can help analyze your mouse: .

Some of the most useful hotkeys for the mouse wheel involve alternate modes of scrolling a window's text. For example, the following pair of hotkeys scrolls horizontally instead of vertically when you turn the wheel while holding down the left :

~LControl & WheelUp:: ; Scroll left. ControlGetFocus, fcontrol, A Loop 2 ; <-- Increase this value to scroll faster. SendMessage, 0x0114, 0, 0, %fcontrol%, A ; 0x0114 is WM_HSCROLL and the 0 after it is SB_LINELEFT. return ~LControl & WheelDown:: ; Scroll right. ControlGetFocus, fcontrol, A Loop 2 ; <-- Increase this value to scroll faster. SendMessage, 0x0114, 1, 0, %fcontrol%, A ; 0x0114 is WM_HSCROLL and the 1 after it is SB_LINERIGHT. return

Finally, since mouse wheel hotkeys generate only down-events (never up-events), they cannot be used as key-up hotkeys.

Each numpad key can be made to launch two different hotkey subroutines depending on the state of . Alternatively, a numpad key can be made to launch the same subroutine regardless of the state. For example:

NumpadEnd:: Numpad1:: MsgBox, This hotkey is launched regardless of whether NumLock is on. return

If the tilde (~) operator is used with a prefix key even once, it changes the behavior of that prefix key for all combinations. For example, in both of the below hotkeys, the active window will receive all right-clicks even though only one of the definitions contains a tilde:

~RButton & LButton::MsgBox You pressed the left mouse button while holding down the right. RButton & WheelUp::MsgBox You turned the mouse wheel up while holding down the right button.

The Suspend command can temporarily disable all hotkeys except for ones you make exempt. For greater selectivity, use #IfWinActive/Exist.

By means of the Hotkey command, hotkeys can be created dynamically while the script is running. The Hotkey command can also modify, disable, or enable the script's existing hotkeys individually.

Joystick hotkeys do not currently support modifier prefixes such as ^ (Ctrl) and # (Win). However, you can use GetKeyState to mimic this effect as shown in the following example:

Joy2:: if not GetKeyState("Control") ; Neither the left nor right Control key is down. return ; i.e. Do nothing. MsgBox You pressed the first joystick's second button while holding down the Control key. return

There may be times when a hotkey should wait for its own modifier keys to be released before continuing. Consider the following example:

^!s::Send {Delete}

Pressing ++ would cause the system to behave as though you pressed ++ (due to the system's aggressive detection of this hotkey). To work around this, use KeyWait to wait for the keys to be released; for example:

^!s:: KeyWait Control KeyWait Alt Send {Delete} return

If a hotkey label like produces an error like "Invalid Hotkey", your system's keyboard layout/language might not have the specified character ("Z" in this case). Try using a different character that you know exists in your keyboard layout.

A hotkey label can be used as the target of a Gosub or Goto. For example: . See Labels for related details.

One common use for hotkeys is to start and stop a repeating action, such as a series of keystrokes or mouse clicks. For an example of this, see this FAQ topic.

Finally, each script is quasi multi-threaded, which allows a new hotkey to be launched even when a previous hotkey subroutine is still running. For example, new hotkeys can be launched even while a message box is being displayed by the current hotkey.

Alt-Tab Hotkeys

Alt-Tab hotkeys simplify the mapping of new key combinations to the system's Alt-Tab hotkeys, which are used to invoke a menu for switching tasks (activating windows).

Each Alt-Tab hotkey must be either a single key or a combination of two keys, which is typically achieved via the ampersand symbol (&). In the following example, you would hold down the right and press or to navigate the alt-tab menu:

RAlt & j::AltTab RAlt & k::ShiftAltTab

AltTab and ShiftAltTab are two of the special commands that are only recognized when used on the same line as a hotkey. Here is the complete list:

AltTab: If the alt-tab menu is visible, move forward in it. Otherwise, display the menu (only if the hotkey is a combination of two keys; otherwise, it does nothing).

ShiftAltTab: Same as above except move backward in the menu.

AltTabMenu: Show or hide the alt-tab menu.

AltTabAndMenu: If the alt-tab menu is visible, move forward in it. Otherwise, display the menu.

AltTabMenuDismiss: Close the Alt-tab menu.

To illustrate the above, the mouse wheel can be made into an entire substitute for Alt-tab. With the following hotkeys in effect, clicking the middle button displays the menu and turning the wheel navigates through it:

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

To cancel the Alt-Tab menu without activating the selected window, press or send . In the following example, you would hold the left and press to display the menu and advance forward in it. Then you would release the left to activate the selected window, or press the mouse wheel to cancel. Define the AltTabWindow window group as shown below before running this example.

LCtrl & CapsLock::AltTab #IfWinExist ahk_group AltTabWindow ; Indicates that the alt-tab menu is present on the screen. *MButton::Send {Blind}{Escape} ; The * prefix allows it to fire whether or not Alt is held down. #If

If the script sent (such as to invoke the Alt-Tab menu), it might also be necessary to send as shown in the example further below.

Currently, all special Alt-tab actions must be assigned directly to a hotkey as in the examples above (i.e. they cannot be used as though they were commands). They are not affected by #IfWin or #If.

An alt-tab action may take effect on key-down and/or key-up regardless of whether the keyword is used, and cannot be combined with another action on the same key. For example, using both and is unsupported.

Custom alt-tab actions can also be created via hotkeys. As the identity of the alt-tab menu differs between OS versions, it may be helpful to use a window group as shown below. For the examples above and below which use , this window group is expected to be defined in the auto-execute section. Alternatively, can be replaced with the appropriate for your system.

GroupAdd AltTabWindow, ahk_class MultitaskingViewFrame ; Windows 10 GroupAdd AltTabWindow, ahk_class TaskSwitcherWnd ; Windows Vista, 7, 8.1 GroupAdd AltTabWindow, ahk_class #32771 ; Older, or with classic alt-tab enabled

In the following example, you would press to display the menu and advance forward in it. Then you would press to activate the selected window, or press to cancel:

*F1::Send {Alt down}{tab} ; Asterisk is required in this case. !F2::Send {Alt up} ; Release the Alt key, which activates the selected window. #IfWinExist ahk_group AltTabWindow ~*Esc::Send {Alt up} ; When the menu is cancelled, release the Alt key automatically. ;*Esc::Send {Esc}{Alt up} ; Without tilde (~), Escape would need to be sent. #If

Function Hotkeys [v1.1.20+]

One or more hotkeys can be assigned a function by simply defining it immediately after the hotkey label as in this example:

; Ctrl+Shift+O to open containing folder in Explorer. ; Ctrl+Shift+E to open folder with current file selected. ; Supports SciTE and Notepad++. ^+o:: ^+e:: editor_open_folder() { WinGetTitle, path, A if RegExMatch(path, "\*?\K(.*)\\[^\\]+(?= [-*] )", path) if (FileExist(path) && A_ThisHotkey = "^+e") Run explorer.exe /select`,"%path%" else Run explorer.exe "%path1%" }

[v1.1.28+]: Hotstrings can also be defined this way. Multiple hotkeys or hotstrings can be stacked together to call the same function.

There must only be whitespace, comments or directives between the hotkey/hotstring labels or label and the function. Hotkey/hotstring labels defined this way are not visible to IsLabel(), Gosub or other commands; however, the auto-execute section ends at the first hotkey/hotstring even if it is assigned a function.

The main benefit of using a function is that local variables can be used, which avoids conflicts when two or more hotkeys use the same variable names for different purposes. It also encourages self-documenting hotkeys, like in the code above where the function name describes the hotkey.

The Hotkey command can also be used to assign a function or function object to a hotkey.


You will also like:


2215 2216 2217 2218 2219