Sample Macro

Context Menu Macros

Written by Kevin Heaton, Insight Software Solutions, Inc.

What it does

These macros allow you to add entries to the Windows context menu that allow you to run a macro by right-clicking on a file, folder or drive letter from the desktop or within My Computer or Windows Explorer.

To install

Download the macro file umcontextmenumacros.zip and save it to your hard drive. Unzip the files and save them in the folder where you store your macro file(s). Import the macros into your existing macro file by clicking File, Import, Import Macros.

To use

Using the sample macro ‘Context Macro’ as an example, write a macro that you want to run when you right-click on a file, folder or drive letter. Then run the ‘Add entry to Context Menu’ macro.

When the ‘Add entry to Context Menu’ macro runs you will be asked to enter the Context Menu Location, the text you want displayed when you right-click on something and the name of the macro to run. Default values for these are supplied.

The Context Menu Location determines when the text to describe your macro is displayed. If you choose Files the entry will be available whenever you right-click on any file in any folder. Choosing Drives will make the entry available whenever you right-click on a drive letter. Similarly, the Folders and Directories choices will make the entry available when you right-click on the name of a folder.

The Folders, Directories and Drives choices overlap somewhat. If you right click on a drive letter in My Computer / Windows Explorer then the context menu entry for ‘Folders’ and ‘Drives’ will be displayed. If you click on the name of a folder, however, the context menu entry for ‘Folders’ and ‘Directories’ is available.

Run the ‘Delete Context Menu entry’ macro to remove the entry from the Windows context menu.

How it works

This macro adds entries in the HKEY_CLASSES_ROOT area of your registry that causes Windows to display your selected text in the appropriate context menus. When you right-click on a file, folder or drive letter, Windows calls the meproc.exe program that is part of Macro Express and passes the name of the file, folder or drive letter to a memory location for the T1 variable. The Variable Restore command in the ‘Context Macro’ loads the value from memory and saves it in T1.

The macro that runs when you right-click on a file, folder or drive letter can be written to perform different things depending on what was clicked. The ‘Context Macro’ macro provides an example of how to do this.

Requirements

Macro Express 3.5 or later

Submitted by

These macros were written by Kevin Heaton of Insight Software Solutions, Inc. They are based on the example posted in the Macro Express 3.x discussion forum by Paul Thornett with additional information from Gary Britt. See the entire discussion by visiting Right Click On A File?