Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Drag and drop (http://www.velocityreviews.com/forums/t891121-drag-and-drop.html)

 Tino 03-02-2005 03:12 PM

Drag and drop

I would like to be able to drag and drop files onto a .pl file in the same
way I can drop files onto a .bat file. I made a .bat which can do this but
if I try to do the same thing with a .pl file I find the .pl file isn't able
to accept files for drag and drop operations, the cursor changes to the "not
allowed operation" symbol when the file being dropped is over the .pl file.
What do I have to do to the .pl file to make it work like the .bat file?

Example of .bat file onto which a file can be dropped:

@echo off
:plot_loop
print.pl p=1 %1
shift
if not "%1"=="" goto plot_loop

Example of .pl file that I would like to do the same as the .bat file:

use strict;
use warnings;

foreach (@ARGV) {
system("print.pl p=1 $_"); } regards Peter  GreenLeaf 03-03-2005 02:07 AM Re: Drag and drop Tino wrote: > I would like to be able to drag and drop files onto a .pl file in the same > way I can drop files onto a .bat file. I made a .bat which can do this but > if I try to do the same thing with a .pl file I find the .pl file isn't able > to accept files for drag and drop operations, the cursor changes to the "not > allowed operation" symbol when the file being dropped is over the .pl file. > What do I have to do to the .pl file to make it work like the .bat file? > > Example of .bat file onto which a file can be dropped: > > @echo off > :plot_loop > print.pl p=1 %1 > shift > if not "%1"=="" goto plot_loop > > > Example of .pl file that I would like to do the same as the .bat file: > > use strict; > use warnings; > > foreach (@ARGV) { > system("print.pl p=1$_");
> }
>
>

Not the exact answer to your question; but if you just need to _get the
job done_, two alternatives are

1. use the following one-liner batch file that calls the perl script in
turn.

@perl "path\to\script\thescript.pl" %*

2. consider compiling the perl script in to a Windows executable.

 Fabian Pilkowski 03-03-2005 05:27 AM

Re: Drag and drop

* Tino wrote:
>
> I would like to be able to drag and drop files onto a .pl file in the same
> way I can drop files onto a .bat file. I made a .bat which can do this but
> if I try to do the same thing with a .pl file I find the .pl file isn't able
> to accept files for drag and drop operations, the cursor changes to the "not
> allowed operation" symbol when the file being dropped is over the .pl file.
> What do I have to do to the .pl file to make it work like the .bat file?

If you've a version of ActiveState's Perl installed have a look into its
bin-directory. You will find a small tool named "pl2bat.bat" which wrap
your perl code into a batch file.

Otherwise you can add a new key to your windows registry to imitate the
behavior of batch files. Then you can drag and drop your files directly
to you perl script. Just create the key

HKEY_CLASSES_ROOT\Perl\shellex\DropHandler\

with default value set to "{86C86720-42A0-1069-A2E8-08002B30309D}".
winxp machine. Perhaps you wanna compare this with your own system
settings. I've copied this value from

HKEY_CLASSES_ROOT\batfile\shellex\DropHandler\

regards,
fabian

 Tino 03-07-2005 01:27 PM

Re: Drag and drop

"Fabian Pilkowski" <pilkowsk@informatik.uni-marburg.de> wrote in message
news:MPG.1c90be9c39b020a69898b9@news.individual.de ...
>* Tino wrote:
>>
>> I would like to be able to drag and drop files onto a .pl file in the
>> same
>> way I can drop files onto a .bat file. I made a .bat which can do this
>> but
>> if I try to do the same thing with a .pl file I find the .pl file isn't
>> able
>> to accept files for drag and drop operations, the cursor changes to the
>> "not
>> allowed operation" symbol when the file being dropped is over the .pl
>> file.
>> What do I have to do to the .pl file to make it work like the .bat file?

>
> If you've a version of ActiveState's Perl installed have a look into its
> bin-directory. You will find a small tool named "pl2bat.bat" which wrap
> your perl code into a batch file.
>
> Otherwise you can add a new key to your windows registry to imitate the
> behavior of batch files. Then you can drag and drop your files directly
> to you perl script. Just create the key
>
> HKEY_CLASSES_ROOT\Perl\shellex\DropHandler\
>
> with default value set to "{86C86720-42A0-1069-A2E8-08002B30309D}".
> winxp machine. Perhaps you wanna compare this with your own system
> settings. I've copied this value from
>
> HKEY_CLASSES_ROOT\batfile\shellex\DropHandler\
>
> regards,
> fabian

Thanks. I tried both options and they both work so I will go with drag and
drop directly onto the Perl script. As per your example I used the
DropHandler value from "batfile". I wonder if there is a more appropriate
value for "Perl"?

 A. Sinan Unur 03-07-2005 02:00 PM

Re: Drag and drop

"Tino" <chamynpj@___brightonline.com.au> wrote in
news:d0hkre$pn9$1@news-02.connect.com.au:
>
> "Fabian Pilkowski" <pilkowsk@informatik.uni-marburg.de> wrote in
> message news:MPG.1c90be9c39b020a69898b9@news.individual.de ...

....

>> Otherwise you can add a new key to your windows registry to imitate
>> the behavior of batch files. Then you can drag and drop your files
>> directly to you perl script. Just create the key
>>
>> HKEY_CLASSES_ROOT\Perl\shellex\DropHandler\
>>
>> with default value set to "{86C86720-42A0-1069-A2E8-08002B30309D}".

....

> Thanks. I tried both options and they both work so I will go with drag
> and drop directly onto the Perl script. As per your example I used the
> DropHandler value from "batfile". I wonder if there is a more
> appropriate value for "Perl"?

No. That is the excutable drag & drop handler. A quick look through the
registry would have shown you that that value is the same for exe, pif etc
files as well.

Sinan

 All times are GMT. The time now is 04:35 AM.