Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Taking argument via drag-drop to a perl script

by exilepanda (Pilgrim)
on Dec 04, 2018 at 04:11 UTC ( #1226695=perlquestion: print w/replies, xml ) Need Help??

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

Hello monks, I am working on Windows, and have associated .plx as direct run perl script. It means, when I double click on a .plx file, Windows will invoke the perl interpreter to run the script file. Now I wonder if I can drag drop another dir/file/shortcut to the .plx file, and the .plx file could somehow retrieve the file path as argument.

I actually have a workable solution, which is to create a .bat file as the argument taking interface, and then forward to the script via %1 %2... But I'd like to see if this can be more straight forward (ie. directly drop on the .plx file). Thank you very much for any clues.

  • Comment on Taking argument via drag-drop to a perl script

Replies are listed 'Best First'.
Re: Taking argument via drag-drop to a perl script
by kschwab (Vicar) on Dec 04, 2018 at 05:27 UTC
    From StackOverFlow:

    Add a drop handler Adding a drop handler for Perl allows you to run a Perl script via drag & drop; e.g. dragging a file over the file icon in Windows Explorer and dropping it there. Run the following script to add the necessary entries to the registry:

    use Win32::TieRegistry; $Registry->Delimiter("/"); $perlKey = $Registry-> {"HKEY_CLASSES_ROOT/Perl/"}; $perlKey-> {"shellex/"} = { "DropHandler/" => { "/" => "{86C86720-42A0-1069-A2E8-08002B30309D}" }};
    Also, some other ideas here.

      Any idea what that cryptic hex (i assume) string is? Is it MS's way of telling us they are the high priests of computing?

      If they were, a mere 42 would have been perfectly sufficient. But they botched that up: the tally is only 41 ...

      sub sumit { my $sum = 0; map { $sum += $_ } split //, @_ ? $_[0] : $_; $sum } my @sums = map { sumit } map { sumit hex } split /\-/, '86C86720-42A0- +1069-A2E8-08002B30309D'; print sprintf "%s\n", join '+', @sums;

      bw, bliako

        You've never seen UUID/GUID before? You can generate them from Perl, using modules like Data::GUID or Win32API::GUID. A Windows registry is chock-full of UUID, which are used for uniquely identifying handlers, objects, and the like. And they weren't even invented or standardized by Microsoft: there are equivalent standards among various bodies, including the Open Software Foundation, ISO/IEC, and IETF.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1226695]
Approved by Albannach
Front-paged by haukex
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2020-02-17 09:01 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (71 votes). Check out past polls.