Drag and drop

T

Tino

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
 
G

GreenLeaf

Tino said:
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.
 
F

Fabian Pilkowski

* Tino said:
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}".
Don't ask something about this CLSID, for me this works on a german
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
 
T

Tino

Fabian Pilkowski said:
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}".
Don't ask something about this CLSID, for me this works on a german
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

A. Sinan Unur

Tino said:
message
....

....

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top