pht has asked for the wisdom of the Perl Monks concerning the following question:

Hello, this is actually two questions is one post:

1. I understand that I can edit the windows registry (somewhere in hkey_classes) to create a single explorer context menu item that can launch my perl script. Is there a way to create context item with sumbenus or icons - sort of like winzip or 7zip has? I'm thinking that this requires some dll trickery, that is beyond my understanding - is something like that possible with perl?

2. Suppose I create that single menu item that launches my script (thru the registry). When I select multiple files in explorer and select the context menu item, it launches multiple instances of my script, each for one file. What should I do to drive all the arguments into one instance of my program (again, like the zip thingies do)? I have worked around that by putting my script in the "Send To" folder in the past, but that one has also its drawbacks.

  • Comment on Hooking scripts to context menu items in windows explorer

Replies are listed 'Best First'.
Re: Hooking scripts to context menu items in windows explorer
by cdarke (Prior) on Oct 08, 2008 at 08:52 UTC
      urgh, that looks exactly like the dll trickery. any ideas how to do it with perl? or about embedding perl classes into dlls?
        The only way I know of is to write it in XS - yep, DLL trickery.
Re: Hooking scripts to context menu items in windows explorer
by ikegami (Patriarch) on Oct 08, 2008 at 08:56 UTC

    Not quite what you asked, you can get almost what you want by putting a shortcut to your script in C:\Documents and Settings\{username}\SendTo.

    Does C:\Documents and Settings\All Users\SendTo also get checked? Gotta run, no time to test.

      Nope, putting it in All Users does not work. As I said, I know about the Send To alternative, though it has its disadvantages - that's extra click and a limit on the number of arguments passed to the script ...