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

Hey!

I was just wondering if anyone here had any idea how to get the rightclick menu to show using Perl? (and assumably using Win32::API and/or Win32::GUI).

I also assume one have to "select" a file/files somehow before showing that. In either case, it would be nice if anyone here had any idea how to do it (or somewhere to start).

Thanks,
Ace

Replies are listed 'Best First'.
Re: Explorer's Right-Click Menu
by Corion (Patriarch) on Dec 21, 2005 at 13:48 UTC

    Adding a right-click entry in Windows Explorer is done by adding a registry key at the right location. Look in the Microsoft documentation or, much easier, steal from the XP Power Toys. The "Command Prompt Here" extension adds such a right-click entry.

    Personally, I've moved to adding a shortcut into the "Send To" menu instead, because the interface is more maintainable by the end user.

    In both cases, you need to make sure that the command line is not your Perl script (.pl) but perl.exe -w "c:\your\Perl\script.pl" "%1", or your Perl script will never receive the command line arguments. My way of doing that is to actually call a batch file first:

    @echo off rem First, chdir into the directory where this batch file (and our Per +l script) reside: cd /d "%~dp0" rem Now, invoke our Perl script: C:\perl\bin\perl.exe myscript.pl "%1"
      I wanted the menu to show up. (and depending on what is selected, different things are shown in the list (this is taken care of internally by Windows I suppose...) (Among other things, the "Send to" is shown in this list aswell...)

        So look at what registry key the XP Power Toys "Command Prompt Here" uses, use a similar key, and use Win32::TieRegistry to set it.

        A reply falls below the community's threshold of quality. You may see it by logging in.

      I think you've misunderstood the OP (not that it's that hard to do with such a poorly phrased question); the way I read it they want to somehow programmatically get the right click menu to post itself.

      A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Explorer's Right-Click Menu
by traveler (Parson) on Dec 21, 2005 at 16:42 UTC
    I googled for windows modify right-click menu and this tutorial came up as the first item. It tells you what to do by hand. It was mentioned earlier to use Tie::Registry to do the registry editing. That should get you started.
      Ah, yes. found that too. But as I got it that is about modifying the menu. I just wanted it to pop up... although that is nice too. But still, I need the menu to pop up after I modified it... I guess I want to simulate a rightclick on a file in explorer...