Snippets Help

The favorites of type "Snippet" allow to paste pieces of text into the active application using the QAP popup menu or hotkeys.

Creating snippets

  1. In the Settings window, click the Add button and select the type Snippet.
  2. In the Add Favorite dialog box, give the snippet a name for the menu and enter the text in the Content text box.
  3. Set the menu options as for any other type of favorites and save the favorite snippet.

In the Content text box, by default, pressing Enter or Tab will add an end-of-line or tab. When a snippet is saved to the settings file (quickaccesspopup.ini), these characters are automatically be converted to symbols `n  (new line) and `t  (tab). If you prefer, uncheck the Automatically encode end-of-lines and tabs and manage these characters manually: insert `n for end-of-lines, `t for tabs and ` ` (double-backtick) if you need to insert the backtick character.

Pasting snippets

You can paste snippets as you would launch other types of favorites:

  1. Select the keyboard insertion point in a text zone of the active window.
  2. Click the QAP mouse trigger (by default, middle mouse button) or hit the QAP keyboard hotkey (by default, Windows + W).
  3. In the popup menu, select the snippet. It will be pasted at the keyboard insertion point in the targeted window.

Note: If you open the popup menu by clicking the QAP icon in the Notification zone (Windows Tray), middle-clicking in the task bar or the Desktop, the window active lose the focus (become inactive) when the popup menu is open. In order to paste its content, QAP will ask you to activate the window where you want to send the snippet. QAP will display a message asking you to select the target window and hit the Enter key when you are done. You have up to 10 seconds to select the target application, set the keyboard insertion point and press Enter.

There are two types of snippets: text and macro.

Text snippet
By default, snippets are of type Text containing characters, end-of-lines and tabs. When you select a text snippet in the popup menu, its content is sent to the active application at the current insertion point as you would do using the Windows Clipboard Paste command. The previous content of the Clipboard is saved before pasting the snippet and is restored right after.

Text snippets tips and tricks

  • When trying to paste a snippet from the popup menu, some application or control (text area) may lose focus when the QAP menu is popped up making it impossible to paste the snippet in the active window. Pasting a snippet to the Explorer address bar is one example. An alternative is to assign a hotkey to the snippet (Edit Favorite, in Menu Options tab). When invoked from a keyboard hotkey, the focus has much more chances to stay in the active window.

Macro snippet

The second type of snippet, Macro, is for users with some experience with scripting language. To create a macro snippet, open the Advanced Settings in the Add/Edit favorite dialog box and select Macro mode. Instead of pasting the snippet, QAP sends its content to the active application as keystrokes that you would type at the keyboard. Macro snippets support the AHK special characters allowing to send special keystrokes like Backspace, Home, Control, etc.

Here are some QAP special commands supported in macro snippets:

  • {&Sleep:n} or {&n}: pause sending the snippet for n milliseconds (see AHK Sleep documentation)
    For example: {&Sleep:1000} or {&1000} to insert a one second pause while sending the snippet
  • {&SetKeyDelay:n, option}: slow down the execution of the snippet (see AHK SetKeyDelay documentation)
    For example: {&SetKeyDelay:50} to insert a 50 ms delay between each keystroke in the snippet
  • {&KeyWait:keyname, options}: pause sending the snippet until user press the specified key (see AHK KeyWait documentation, option D is set by default, additional option B available to sound "Beep" when snippet is suspended)
    For example: {&KeyWait:Space,B} to stop the macro snippet execution, sound "beep" and wait until user pushes down the space bar

Here is a full working macro snippet example. This macro snippet will launch Notepad, beep and wait for the space bar keypress, type some text, wait for the Shift keypress, add some text and open the Notepad Save dialog box:

{&SetKeyDelay:50}#r{&500}notepad{Enter}{&KeyWait:Space,B}{Backspace}You are
in {&KeyWait:Shift}Notepad{!}`nChoose a location to save this file...{&500}^s


  • {&SetKeyDelay:50} : slow down the snippet execution with a 50 ms delay between each keystroke
  • #r : press Windows + R to open the Windows Run dialog box
  • {&500} : insert an half-second pause
  • notepad{Enter} : type notepad and press Enter to launch Notepad
  • {&KeyWait:Space,B} : beep and wait for the space bar keypress
  • {Backspace} : erase the space inserted in the previous step
  • You are in : type this text
  • {&KeyWait:Shift} : wait for the Shift keypress
  • Notepad : type this text
  • {!} : type the exclamation mark (enclosed because ! is an AHK special character, see AHK doc)
  • `n : insert an end-of-line character (see AHK doc about "escaped characters")
  • Choose a location to save this file... : type this text
  • {&500} : wait for another half-second
  • ^s : press Control + S to open the Notepad Save dialog box

Macro programming experience is strongly recommended before using this feature. If you need help writing AHK macro, I recommend searching answers or asking question in the "Ask for help" section of the AHK forum where you will find plenty of knowledgeable people who love helping new macro programmers. You can also learn it with these books.

Can I insert command from the AHK programming language in a snippet of type macro? A QAP macro snippet favorite can send pieces of text and basic commands to your keyboard using the SendInput AHK command. However, it is not the place for full-fledge AHK macro language. Variables, conditional expressions (if), loops, etc. are not supported in macro snippet. But you can easily write a macro using a text editor, save it in a file with .ahk extension and launch your AHK macro from QAP. Create a QAP favorite of type Application and enter the location of your script (for example c:\AHKscripts\myscript.ahk) in the Application (path and file name).

One comment

Leave a Reply