Can I insert values in favorites location, parameters or snippets using placeholders?

You can insert values from placeholders (like {Clipboard}) in Snippets content and in favorite’s Location, Parameters, Launch with and Start In fields (for all types of favorites supporting these options). Placeholders contents are  based on:

See Debugging placeholders and user variables.

Note: Support for placeholders in Launch with field requires v11.5.6.9.1.

Clipboard

You can use the Windows Clipboard to insert variable pieces of text in your snippets or in various paths in favorites dialog box. When you launch your favorite, QAP automatically replaces the placeholder “{Clipboard}” (without the quotes) with the current content of the Windows Clipboard.

For example, in the following Snippet example, the Clipboard’s content will be inserted in the second line between the arrows. If the Clipboard contains an image or binary data, nothing is inserted.

In this second example, the content of the clipboard is sent as parameter. The content of the Parameters zone is expanded in the preview zone named Current parameters with expanded placeholders at the bottom of the dialog box. It shows what would be the parameter sent to the application with the current Clipboard’s content.

The example above is a working example for browsers applications Chrome, Firefox and Internet Explorer. This parameter will automatically launch your browser to search for the text contained in your Windows Clipboard. Make sure you include the quotes correctly to include all word in the search. If you want to search for an exact expression, add surrounding quotes like this: "? \"{Clipboard}\"" (these browsers consider the backslash “\” as an escape character for quotes inside the parameter).

If you use the browser Microsoft Edge, simply enter in the Parameters zone {Clipboard} (no quotes) for a normal search or "{Clipboard}" (with quotes) to search for an expression.

Favorite’s location

In an Application favorite, you can re-use the favorite’s location (or part of it) in the Start In or the Parameters fields. For example {DIR} in the the Start In field will be replaced with the favorite’s location folder. The following examples are based on the favorite’s location C:\MyFolder\MyFile.exe:

  • {LOC} for full location (C:\MyFolder\MyFile.exe)
  • {NAME} for file name (MyFile.exe)
  • {DIR} for directory (C:\MyFolder)
  • {EXT} for extension (exe)
  • {NOEXT} for file name without extension (MyFile)
  • and {DRIVE} for drive letter. (C:)

In the following example, an Application favorite named My App with data file will be open with a parameter based on the application’s folder.

The Parameters field below includes the {DIR} placeholder with a file name Client.DAT. The second red box shows that the {DIR} placeholder will be expanded taking into account the applications’ location from the above screen capture.

Multiple parameters can be inserted in this field. Each parameter must be enclosed between quotes. Also, do not forget that, even if there is only one parameter, a parameter must be enclosed between quotes if it contains spaces.

Current folder in Explorer

You can also use the placeholders {CUR_LOC}, {CUR_DIR}, etc. that will be replaced with the current location of your Explorer window (window under the mouse pointer or active Explorer window when you open the menu). Let’s say you have various folders with the same subfolders structure, for example:

C:\Client-1
C:\Client-1\Contract
C:\Client-1\Contract\Draft
C:\Client-1\Contract\Signed
C:\Client-2
C:\Client-2\Contract
C:\Client-2\Contract\Draft
C:\Client-2\Contract\Signed
etc.

You can create favorites of type Folder or Document that will be opened in a given subfolder under the current (or active) folder in Windows Explorer. For example, a favorite Folder named Current Client’s Signed Contract would open the Signed subfolder for Client-1 if you are in the C:\Client-1 folder, or for the second client if you are in C:\Client-2, etc.

Create a favorite folder with the Folder (path) {CUR_LOC}\Contract\Signed in the Basic Settings tab:

When you will launch this favorite, QAP will get the current folder (in Windows Explorer, Directory Opus or Total Commander) and will replace the placeholder {CUR_LOC} with the detected current folder’s location. To avoid “folder not found” errors, make sure you have a strictly constant subfolders structure and that you always use this favorite in the appropriate folder (a “root” client folder in our example).

Current (or active) folder in Windows Explorer placeholder can be inserted in location for favorites of types Folder, Document and Application. You call also use these placeholder variations. The following examples are based on the current (or active) folder location C:\Parent\Child.dir:

  • {CUR_LOC} for full location (C:\Parent\Child.dir)
  • {CUR_NAME} for file name (Child.dir)
  • {CUR_DIR} for directory (C:\Parent)
  • {CUR_EXT} for extension (dir)
  • {CUR_NOEXT} for file name without extension (Child)
  • and {CUR_DRIVE} for drive letter (C:)

See also this page for more info about the Start In and Parameters settings: Can I pass the current folder as parameter to an application launched with QAP?.

Note-1: Remember that, in QAP, the relative path conventions .\ for current folder or ..\ for parent folder are processed relatively to QAP’s Settings Folder, not to the current directory in your Explorer window.

Note-2: The current location cannot be detected by QAP for some dynamic folders or libraries (like Music or Videos). For example,  the Desktop folder is a dynamic folder combining the content from the user’s Desktop (C:\Users\UserName\Desktop) and from the Common Desktop (C:\Users\Public\Desktop). In this case, QAP detects that the current folder is the Desktop but, because it can’t distinguish between these two dynamic sources, it will always use the C:\Users\UserName\Desktop as current location since it is the most frequently used folder.

Selected file or folder in Explorer

Similar to using the context menu with Right-Click but with much more flexibility, you can use QAP to pass the location of the selected file (or part of it) to a given favorite application or script.

In the following example, when launching the application favorite MyApp, QAP will replace  the {SEL_NAME} placeholder in the Parameters zone with the file name of the item under the mouse pointer when you open the QAP menu with the Middle Mouse Button or the selected file in the current file manager window if you open the menu with the keyboard shortcut (Windows + W).

Open the QAP menu by pressing the Middle Mouse Button while the mouse pointer is over the desired file and launch the favorite. In the following example, the favorite application is showing a dialog box with, as parameter, the name of the selected file quickaccesspopup-9_1_2.zip.

These placeholders work in Windows Explorer and Directory Opus. They are not available in Total Commander at this time.

Available placeholders for the selected file are (examples are based on a selected file C:\Parent\Child\Name.Ext):

  • {SEL_LOC} for full location (C:\Parent\Child\Name.Ext)
  • {SEL_NAME} for file name (Name.ext)
  • {SEL_DIR} for directory (C:\Parent\Child)
  • {SEL_EXT} for extension (Ext)
  • {SEL_NOEXT} for file name without extension (Name)
  • and {SEL_DRIVE} for drive letter (C:)
Active window

Starting with v11.5.6.9.1, you can open Documents, Links and FTP favorites in the active window using the placeholder {ActiveWindow} in the Launch with this application property of the favorite in the Advanced Settings tab. To be the “active window”, an application must be at the foreground and, generally, have the keyboard or mouse focus.

For example, if you have Notepad and Notepad++ text editors running at the same time on your system, if you select in your QAP menu a document favorite for a text file with this option, it will be open in one of these editors if one of them is currently the “active window”. The same is true for Link favorites and if you have two different browsers (like Chrome and Firefox) running at the same time on your system.

To open the favorite with the active window, QAP is using the Windows Run command using the active application path with the favorite’s path as parameter. Most of the time, the application will open the document in a new tab or a new internal window. However, in some case (for example with Notepad), the document will be open in a new instance (a new window) of the same application.

At this time, for safety, before launching a favorite, QAP displays a confirmation prompt with the path of the active widow. An option could be added in the future to bypass this prompt. If you need it, please raise this issue on the QAP forum.

User Input

Using the placeholder {Input:prompt} you can enter a different content at each launch of a snippet or favorite.

The prompt inside the parameter will be displayed as a prompt in the input box, In the example below, QAP will open the folder c:\clients\ABC123.

Starting with QAP v11.5.2, the content entered by the user can be re-used in the same favorite thanks to a temporary user variable named based on the prompt of the Input placeholder. For example, in a Snippet with a placeholder {Input:Enter Client ID}, a temporary user variable named {Enter client ID} would allow to paste the ID of the client again later in the same snippet.

Current date or time

The placeholder {Now:format} inserts in favorite’s location or in a snippet the date or time at the moment the favorite is launched. The date and/or time is inserted following the syntax described in the AHK FormatTime command, for example:

  • {Now:yyyy-MM-dd} -> 2022-03-13
  • {Now:dddd hh:mm} -> Sunday 14:06
  • {Now:MMMM d, yyyy h:mm tt} -> March 13, 2022 4:30 PM

In addition to the AHK format the format {Now:ld} allows to insert the last day of the current month (requires v11.5.6). You can combine this with other {Now:...} placeholders to form a complete date, for example:

  • {Now:ld} -> 28, 29, 30 or 31 depending on the current month
  • {Now:MMMM} {Now:ld}, {Now:yyyy} -> February 28, 2022

These placeholders can be inserted in locations, for example:

C:\reports\{Now:yyyyMM} for the folder of the current month (as in C:\reports\202203)

or in Snippets, for example:

Report sent on {Now:MMMM d, yyyy} at {Now:hh:mm tt}

Add UTC at the end of the format string to insert Universal Coordinated Time, for example: Report sent at {Now:h:mm UTC} UTC

Date and time calculation

You can also insert future or past dates and time using calculation with the following syntax (requires v11.5.6):

  • {Now[sign][value pairs]:[format]}
  • where [sign] is either + (plus) or - (minus);
  • [value pairs] is one or more pairs of:
    • a number (integer);
    • a time unit identified by one of the letters smhdMy (case sensitive) for seconds, minutes, hours, days, Months or years;
  • and [format] is the date or time format as described above.

For example (supposing we are March, 13, 2022 at 4h30 PM):

  • {Now+1d:yyyy-MM-dd} (tomorrow)-> 2022-03-14
  • {Now-1y6M:yyyy-MM-dd} (1.5 year ago) -> 2020-09-13
  • {Now+3h30m:h:mm tt} (in 3.5 hour from now) -> 8:00 PM (or else, depending on regional settings)
  • {Now-1M:yyyy-MM}-{Now-1M:ld} (last day of previous month) -> 2022-02-28
  • {Now-30d:yyyy-MM-dd} (30 days ago) -> 2022-02-11
  • {Now+1M10d:yyyy-MM-dd} (in 1 month and 10 days) -> 2022-04-23
  • {Now-7h35m:HH:mm} time 7 hours and 35 minutes ago, in 24-hour format -> 08:55

Debugging placeholders and user variables

Starting with QAP v11.5.2, you can test the effect of your placeholders and user variables in your favorites by enabling the Favorite debugging for placeholders and user variables in Options, Various Advanced Options tab.

When this option is enabled, an additional checkbox will be available in the Add/Edit Favorite dialog box Basic Settings tab allowing to enable debugging for this favorite.

When this option is enabled, instead of launching the favorite, QAP will display a dialog box containing the location (with parameter and Start in folder if applicable) expanded with the content of the placeholders and user variables. Disable the debug option to use your favorite.