Tuesday, March 18, 2008

Windows Stuff: Adding Custom Actions to Context Menus

This post is pretty simple, it's really to immortalize some pretty simple stuff that I seem to keep forgetting in my head. Blogging something has a tendency to sear things into my head.

Larry Wall once listed the three chief virtues of the programmer as: Laziness, Impatience and Hubris. This is really about the first quality. I downloaded Paint.NET the other day and wanted to be able to open certain types of content with Paint.NET with the context menu (see below). On some of my machines this either isn't available or doesn't work very well. This is how you add commands to the context menu for a given file type. To be clear we want the following behavior.

Custom right click context menu action.

To pull this off is quite simple you first:

  1. Open Windows Explorer, click Tools->Folder Options->File Types(tab) scroll down to the file type you want to add the action for.
  2. After you have your type of file selected (ie. GIF) click Advanced.
  3. Click New to add a new Custom Action, give it a name and then an application to run. You can specify parameters using "%1" "%2" etc...Adding custom action to right click context menu.
  4. It's important to put quotes (") around the parameters in case they happen to be in paths that involve white space. I won't really take the time to get in to DDE because I've never really gotten it to work consistently.
  5. Finally click OK and you should be off to the races.

Short but sweet,
Tyler

1 comment:

electronic signatures said...

I just want to thank you for the work that you do and your willingness to share. You have created outstanding materials and we all benefit from your generosity.