# ContextMenu

The **ContextMenu** command can be used to:

* Display a list of the context menu commands that are available for selected files, and
* Trigger a context menu command for selected files without needing to first display the context menu (so you can, for example, configure a button or hotkey to execute a command that is normally only available from the context menu)

The first step in using the **ContextMenu** command is to select the file (or a file of the type) in question and use the **SHOWCMDS** argument to view the available context menu commands. The easiest way to do this (unless you want to set up a button dedicated to this) is to use the [**find-as-you-type**](../../../basic_concepts/the_lister/find-as-you-type_field) field in **Command** mode.

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-a8e9c5bf06be6595a462686fab02508b8b077290%2Fcontextmenu_via_fayt.png?alt=media)

Opus will display a dialog containing a list of the available context menu commands. Context menu commands have an ID number and some may also have a "verb" - a plain text string that you can use to invoke the command. If a command has a verb displayed you should use this in preference to the ID, as it's possible for the ID number to change if additional context menu extensions are installed. You can also trigger a command by its label using the **LABEL** and **LABELRAW** arguments (and these can optionally use wildcards or regular expressions).

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-61dadf74448734aa9dc9661f8ff3e5a7a9222034%2Fcontextmenucmds.png?alt=media)

The _Context Menu Commands_ dialog can automatically create a command line for you - right-click on the command in question, or click the **Copy Command** button to copy the command line to the clipboard.

You can see from this example that the list of commands has been filtered to show only those containing the string "sync" - this has returned two, which are Dropbox Smart Sync commands. The first one has a verb and the second one, for some reason, doesn't. Because the verb isn't consistent it might be better to use the label to trigger this command; for example, you could use **ContextMenu LABEL="Smart Sync\Local"** to run the first command and **ContextMenu LABEL="Smart Sync\Online Only"** to run the second.

Once you know what the verb, label or ID is for the command you want to automate, you can configure your button or hotkey with the appropriate **ContextMenu** command.

**Command Arguments:**

| Argument      | Type      | Possible values                                               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------- | --------- | ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| CTRL          | /S        | _(no value)_                                                  | <p>When invoking a context menu command, tells the command handler to act as if the Ctrl key is held down. What difference this makes (if any) is up to the handler.</p><p><em>Example:</em> <code>ContextMenu CTRL VERB="delete"</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| EXTENDEDVERBS | /S        | _(no value)_                                                  | <p>Enables support for <em>extended verbs</em>. These are context menu commands that are normally only displayed when the <strong>Shift</strong> key is held down.</p><p><em>Example:</em> <code>ContextMenu SHOWCMDS EXTENDEDVERBS</code></p><p>If you use this while invoking a command, you will probably also want to specify the <strong>SHIFT</strong> argument.</p><p><em>Example:</em> <code>ContextMenu EXTENDEDVERBS SHIFT VERB="delete"</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| FILE          | /K/M      | _\<filename>, ..._                                            | <p>Specify the file or files to operate on. If not specified the command will operate on all currently selected files.</p><p>You can use this to execute commands on non-filesystem items, for example the Recycle Bin. To do this requires knowing the item's GUID, which unfortunately is beyond the scope of this help file - but as an example, the GUID for the Recycle Bin is <strong>{645FF040-5081-101B-9F08-00AA002F954E}.</strong> The following command will execute the "empty" verb on the Recycle Bin, causing it to empty.</p><p><em>Example:</em> <code>ContextMenu FILE=::{645FF040-5081-101B-9F08-00AA002F954E} VERB=empty</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ID            | /K/N      | _\<command ID>_                                               | <p>Specify the ID of the context menu command to execute.</p><p>You should use an item's verb or label (in that order, if it has either) in preference to its ID, because the ID may change (with the old ID potentially representing a completely different action) when you add or remove software, or even each time the menu is used.</p><p><em>Example:</em> <code>ContextMenu ID=79</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ITEMMENU      | /O        | <p><em>(no value =</em> <strong>yes</strong>*)***<br>no**</p> | <p>(Windows Vista and above. Has no effect on Windows XP.)</p><p>Note that by default this option is <em>on</em> unless the command is being invoked from a background context menu. You can specify the argument yourself (with either <strong>yes</strong> or <strong>no</strong> parameters) if you wish but normally the default behaviour will be acceptable.</p><p><strong>ITEMMENU</strong> mode indicates that you wish to list or invoke context menu commands in the same way as when a file or folder is right-clicked. Without <strong>ITEMMENU</strong> mode you can usually only list or run commands which only appear when you right-click the background of a folder window.</p><p>The exact difference (if any) that <strong>ITEMMENU</strong> makes is up to the individual command handlers. As with the <strong>EXTENDEDVERBS</strong> argument, some handlers will filter their menu items in or out depending on the mode.</p><p><em>Example:</em> <code>ContextMenu ITEMMENU=yes VERB="PreviousVersions"</code></p>                                                         |
| LABEL         | /K        | _\<label>_                                                    | <p>Specify the label of the context menu command to execute.</p><p>It is better to specify the command's verb, using the <strong>VERB</strong> argument, instead of its label, but not all commands have verbs. (Not all commands have labels, either. Context menu handlers which draw their own items may not provide the labels in a form which Opus can read.) Labels, unlike verbs, are typically language-dependent and may change between versions of software or when different files are selected. Using the label is still preferable to using the ID, however.</p><p>You can use the <strong>REGEXP</strong> or <strong>WILD</strong> arguments if you need to match the label using a pattern, which is most often needed when the label includes part of the selected filename.</p><p>When searching for the label in a menu with sub-menus, Opus will check all of the top-level items first, then the items directly below the top-level sub-menus, then any items nested three levels deep, and so on.</p><p><em>Example:</em> <code>ContextMenu LABEL="Quarantine file"</code></p> |
| LABELRAW      | /K/R      | _\<label>_                                                    | <p>This is the same as the LABEL argument except that it is a "raw" argument which swallows the remainder of the command line. You can use this to specify labels which have embedded quotation marks.</p><p><em>Example:</em> <code>ContextMenu LABELRAW Add To "Zip" File...</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| LOOKUP        | /S        | _(no value)_                                                  | <p>Use in conjunction with the <strong>VERB</strong> argument to make Opus lookup the verb's ID on-the-fly instead of simply passing the verb name to the command handler. You should not normally have to do this but some context menu handlers have bugs that prevent them from doing the lookup themselves.</p><p><em>Example:</em> <code>ContextMenu WANTSYNC LOOKUP VERB="PickLinkSource" FILE "C:\Template Folder"</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| REGEXP        | /S        | _(no value)_                                                  | <p>Used in conjunction with the <strong>LABEL</strong> argument to specify that the label string is a regular expression.</p><p><em>Example:</em> <code>ContextMenu REGEXP LABEL="Add to .*\\zip.*"</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| SHIFT         | /S        | _(no value)_                                                  | <p>When invoking a context menu command, tells the command handler to act as if the Shift key is held down. What difference this makes (if any) is up to the handler. If you use this then you'll probably also want to use <strong>EXTENDEDVERBS</strong> as holding down the shift key also normally causes the extended verbs to be shown, and the menu handler may expect both to be used together.</p><p><em>Example:</em> <code>ContextMenu SHIFT EXTENDEDVERBS VERB="delete"</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| SHOWCMDS      | /S        | _(no value)_                                                  | <p>Displays a list of context menu commands for the selected files. Depending on the context menu handlers installed on your system, the list of commands you get back may differ based on the <strong>EXTENDEDVERBS</strong> and <strong>ITEMMENU</strong> arguments; if you use either of them when finding a command then you should do the same when running that command.</p><p><em>Example:</em> <code>ContextMenu SHOWCMDS</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| VERB          | _default_ | _\<verb>_                                                     | <p>Specify the verb of the context menu command to execute. This is the default argument for the <strong>ContextMenu</strong> command, so the keyword <strong>VERB</strong> does not need to be specified.</p><p><em>Example:</em> <code>ContextMenu PreviousVersions</code></p><p><em>Example:</em> <code>ContextMenu VERB="SevenZipCompressEmail"</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| WANTSYNC      | /S        | _(no value)_                                                  | <p>Requests that the context menu command be run synchronously. In other words, any other commands should wait until the context menu command has completed, instead of running in parallel. This is just a request and the context menu handler may ignore it. Similarly, context menu handlers may choose to run things synchronously even when this argument is not specified.</p><p><em>Example:</em> <code>ContextMenu WANTSYNC LOOKUP VERB="DropHardLinkClone" FILE {sourcepath\$}</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| WILD          | /S        | _(no value)_                                                  | <p>Used in conjunction with the <strong>LABEL</strong> argument to specify that the label string is a wildcard expression.</p><p><em>Example:</em> <code>ContextMenu WILD LABEL="Add to *.zip\*"</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
