• entries
94
127
• views
83610

# Simple context-menu extension. Part 1 - commandline tool redirection

395 views

Updated 2006-02-16: In step 10, it should be 85%% and not 85%. % works as the escape character \, if you want that actual character you'll need two.

What?
Do you have some command line you usually use with files? Like HL2 modding where you have to compile the model through a commandline, or creating fixed-sized thumbnails of images to put on your website? Well if it's a copy-paste action you use alot, then you can easily add it to the context menu in Windows Explorer! It doesn't involve any programming nor Windows Registry hacking! The joys!

It has one drawaback though, you won't get the same flexibility as opening the command console. But then again, you're not programming or anything so this simple solution gives you a simple tool. Duh! =P

How?
I'll illustrate by adding a menu item to explorer that let's you compress any JPEG image to 85% quality just by right clicking on it. Something I do frequently when I'm uploading photos.

I have Windows XP; so basically, I went into the file explorer and did this (see reference pic below):

1. Tools -> Folder Options

2. *click the File Types tab*

3. *select JPG*

4. *click Advanced* (if the button Advanced isn't visible, you probably see a "Default" button - meaning you've changed the default behaviour of JPGs somehow, like installing a image app. I just clicked that and the text changed to "Advanced")

5. -new window opens-

6. *click New*

7. -new window opens-

8. *write the text for the menu item, like "Quality to 85%"*

9. *click Browse and navigate to your ImageMagick root folder, select convert.exe*

10. *add "%L" -quality 85%% "%L" after the file path* (%L is a system variable to the filepath of the file you right-clicked on, we use quotes because the file path might include spaces)

Here's some visual aid:

The actual command line, in my case, is:
"C:\Program Files\ImageMagick-6.2.5-Q16\convert.exe" "%L" -quality 85%% "%L"
Including all the quotes!

End
This is what you should end up with.

YAY!!

I hope to get started on my next project in December. Just have to finish Bling! first hehehe... or maybe not!

Thanks goes out to muer, snk_kid, Washu and DigitalDelusion for proofreading this. Extra thanks to snk_kid for the english Windows XP screeny.

Thats pretty cool, it would be even better though if it was like this:
Change Quality >>
90%
80%
…
10%


Hush! You're exposing my plans! ;)

As I said, this is a quick hack to do something quick. I don't think it's possible to add submenus in the context menu without hooking up a COM object and messing with the windows registry. If I'm wrong, please let me know.

## Create an account

Register a new account