What are snippets? How can I use them to paste frequently used pieces of text?

The favorites of type "Snippet" allow to send pieces of text or keystrokes to the active application using the QAP popup menu, hotstrings or keyboard shortcut. There are two types of snippets:

  • Text snippets
  • Macro snippets

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, by typing its hotstring or by hitting its shortcut), its content is sent to the active application at the current insertion point as you would do using the Windows Clipboard Paste command (although, the content of the Clipboard is not impacted by this action).

See:

Macro snippet

The second type of snippet, Macro, is for users with some experience with scripting language. Instead of pasting the snippet to a text box or editor, 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 BackspaceHomeControl, etc.

See:

 

How do I create a Text Snippet and paste it when I need it?

Snippets are pieces of text that you can paste into the active application using the QAP popup menu, hotstrings or shortcuts. Text snippets can contain characters, end-of-lines and tabs.

Creating a snippet

  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. In this text box, pressing Enter will add an end-of-line and pressing Ctrl + Tab will enter a tab.

  3. If the content does not fit in the Content text zone, you can expand the text box to make editing easier by clicking the + sign. When the content is expanded (as below), use the sign to return to normal display. You can also display the snippet content in fixed font and choose the font size.

  4. In the Menu Options tab, select the parent menu and item position as for other type of favorites. Before saving, you will find it helpful to set a Shortcut or an Hotstring for your snippet. Click one of the two Change buttons (you could set both options if you wish) and set the shortcut or the hotstring as illustrated below.

    In these examples, the selected shortcut (left side) is Shift + Control + H and the hotstring trigger (right side) is #html# (TIP: for hotstrings, use "#" or any other symbol to make the hotstring trigger unique).

  5. Finally, click Add to save the favorite snippet.

Pasting snippets

You can paste snippets in three ways (as for other types of favorites) but the first one is particularly useful for snippets. First, select the keyboard insertion point in a text zone of the active window. Then, paste the snippet using one of these techniques:

  1. If you defined an hotstring (as in the example above, on the right), type the hotstring trigger, in our example: #html# and press Enter or Space. As you press the termination key, the hotstring trigger is replaced (or "expanded") with the content of the snippet. Voilà !
  2. If you defined a shortcut (as the left example above), hit the shortcut key, in our example Shift+Control+H. The snippet is immediately pasted at the keyboard insertion point in the targeted window.
  3. Or open the popup menu and select the snippet. It will be pasted at the keyboard insertion point in the targeted window.

The snippet's content is sent to the active application at the current insertion point as you would do using the Windows Clipboard Paste command. Although, the content of the Clipboard is not impacted by this action.

Snippets tips and tricks

  • 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 active window loses 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.
  • 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 hotstring trigger or a keyboard shortcut to the snippet (Edit Favorite, in Menu Options tab). When invoked from a hotstring or a keyboard hotkey, the focus stays in the active window.
  • When a snippet is edited with the Automatically encode end-of-lines checked, the snippet is saved to the settings file (quickaccesspopup.ini) with end-of-lines and tabs are automatically converted to symbols `n  (new line) and `t  (tab). Backtick characters (accent grave) are saved as double-backtick (``). If you prefer to encode these characters yourselves, uncheck the check box.
  • When pasting the content of a snippet to the active window, QAP inserts three small safety delays. By default, the total duration of these delays is 300 ms (3/10th of a second). If your system is quick enough, you can try to reduce these delays by editing the three values of WaitDelayInSnippet=40|80|180 in the settings file (see How can I edit the file QuickAccessPopup.ini?).

See also:

How do I create a macro Snippet to send special keys to applications or insert pauses when pasting?

The Macro snippets, are for users with some experience with scripting language. To create a macro snippet, open the snippet's Advanced Settings tab 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.

Special keys and commands

Macro snippets support the special keys (defined by scripting language AutoHotkey) allowing to send special keystrokes like Backspace, Home, Control, etc. These special keys are always enclosed between curly brackets, for example: {Backspace}.

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
Macro Snippet Working Example

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).

See also:

What keys can be sent using Macro Snippets?

The following table lists the keys that can be inserted in Snippets of type Macro (each key name must be enclosed in braces). See: How do I create a macro Snippet to send special keys to applications or insert pauses when pasting?

These keys are defined by the scripting language AutoHotkey.com (AHK). See more info about AHK at the end of the page.

These special keys are always enclosed between curly brackets, for example {Backspace}. For this reason, as explained in AutoHotkey documentation, if whenever you need to enter opening or closing curly brackets in your snippet, you will have to enclose them that way: {{} and {}}.

Key Modifiers

The modifiers !+^# 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.

Symbol Key Press Release Examples
! {Alt} {Alt down} {Alt up} !a presses Alt+A
+ {Shift} {Shift down} {Shift up} +abC sends the text "AbC"
!+a presses Alt+Shift+A
^ {Ctrl} {Ctrl down} {Ctrl up} ^{Home} presses Control+Home
# {LWin}
{RWin}
{LWin down}
{RWin down}
{LWin up}
{RWin up}
#e holds down the Win key and then presses the E key
Symbol Meaning
{ } Braces are used to enclose key names and other options, and to send special characters literally. For example, {Tab} is the Tab key and {!} is a literal exclamation mark.

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

Special Keys

 Key  
{F1} - {F24} Function keys. For example: {F12} is the F12 key.
{!} !
{#} #
{+} +
{^} ^
{{} {
{}} }
{Enter} Enter key on the main keyboard
{Escape} or {Esc} Escape
{Space} 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)
{Tab} Tab
{Backspace} or {BS} Backspace
{Delete} or {Del} Delete
{Insert} or {Ins} Insert
{Up} (up arrow) key on main keyboard
{Down} (down arrow) key on main keyboard
{Left} (left arrow) key on main keyboard
{Right} (right arrow) key on main keyboard
{Home} Home key on main keyboard
{End} End key on main keyboard
{PgUp} PageUp key on main keyboard
{PgDn} PageDown key on main keyboard
   
{CapsLock} CapsLock
{ScrollLock} ScrollLock
{NumLock} NumLock
   
{Control} or {Ctrl} Control
{LControl} or {LCtrl} Left Control key
{RControl} or {RCtrl} Right Control key
{Control down} or {Ctrl down} Holds the Control key down until {Ctrl up} is sent. To hold down the left or right key instead, use {RCtrl down} and {RCtrl up}.
   
{Alt} Alt
{LAlt} Left Alt key
{RAlt} Right Alt key (or AltGr, depending on keyboard layout)
{Alt down} Holds the Alt key down until {Alt up} is sent. To hold down the left or right key instead, use {RAlt down} and {RAlt up}.
   
{Shift} Shift
{LShift} Left Shift key
{RShift} Right Shift key
{Shift down} Holds the Shift key down until {Shift up} is sent. To hold down the left or right key instead, use {RShift down} and {RShift up}.
   
{LWin} Left Win key
{RWin} Right Win key
{LWin down} Holds the left Win key down until {LWin up} is sent
{RWin down} Holds the right Win key down until {RWin up} is sent
   
{AppsKey} Menu key (invokes the right-click or context menu)
{Sleep} Sleep key.
{ASC nnnnn} Sends an Alt+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.

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

 

   
{Numpad0} - {Numpad9} Numpad digit keys (as seen when NumLock is ON). For example: {Numpad5} is 5.
{NumpadDot} . (numpad period) (as seen when NumLock is ON).
{NumpadEnter} Enter key on keypad
{NumpadMult} * (numpad multiplication)
{NumpadDiv} / (numpad division)
{NumpadAdd} + (numpad addition)
{NumpadSub} - (numpad subtraction)
   
{NumpadDel} Delete key on keypad (this key and the following Numpad keys are used when NumLock is OFF)
{NumpadIns} Insert key on keypad
{NumpadClear} Clear key on keypad (usually the '5' key when NumLock is OFF).
{NumpadUp} (up arrow) key on keypad
{NumpadDown} (down arrow) key on keypad
{NumpadLeft} (left arrow) on keypad
{NumpadRight} (right arrow) key on keypad
{NumpadHome} Home key on keypad
{NumpadEnd} End key on keypad
{NumpadPgUp} PageUp key on keypad
{NumpadPgDn} PageDown key 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.
{Volume_Down} Reduce the master volume.
{Volume_Up} Increase the master volume.
{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
   
{PrintScreen} Print Screen
{CtrlBreak} Ctrl+break
{Pause} Pause

About AutoHotkey

These keys are defined by the scripting language AutoHotkey.com (AHK) used to develop Quick Access Popup. In QAP Macro Snippets, these keys are sent using the AHK command Send in Input mode. If the command SetKeyDelay is used in a macro snippet, the mode is changed to Event to allow the delay.

See also: How do I create a macro Snippet to send special keys to applications or insert pauses when pasting?

Can I call the Quick Access Popup menu from an AutoHotkey macro?

Yes, but there is small trick you need to know.

First, for those not familiar with AutoHotkey (AHK): this is the programming language used to develop Quick Access Popup. It is also a macro scripting tool. AHK developers could write scripts in which they could integrate a call to open QAP menu by "sending" the QAP menu hotkey (by default Middle mouse button) as if it was pressed by the user.

To call an AHK hotkey in one script from another script using the Send command, in some situations, you must insert the SendLevel, 1 command before the Send command. For example, the script below will call the QAP menu (assuming the mouse trigger for QAP is the default Middle Mouse Button).

#NoEnv
#NoTrayIcon
#SingleInstance Off
SendLevel, 1
Send, {MButton}

If you remove the SendLevel, 1 line, the call will not work. For more info about SendLevel, see AHK doc.