* in the file explorer, right-click on a file [whose name my perl
program provides] and select a particular program to invoke on this
file. For example, this could be "Send To -> Compressed (zipped)
Folder" or "Send to Mail Recipient". In my specific case, I want to
right-click a file to "Abby Finereader -> Convert into ..." or
"OmniPage 16 -> Convert to PDF". Fortunately, there is nothing else
that these invoked programs require as subsequent input.
Then I want to wait until the invoked program is completed and
exits. This is it.
I can write the rest of the program.
Could someone in the know please help?
sincerely,
/iaw
> dear perl experts---I hope this is a request for a one-liner. I usually
> run linux or OSX, but I now am in need of automating some OCR on
> Windows. (The OCR vendors only sell affordable software on Windows in
> their latest versions.) So, I want to automate the following:
>
> * in the file explorer, right-click on a file [whose name my perl
> program provides] and select a particular program to invoke on this
> file. For example, this could be "Send To -> Compressed (zipped)
> Folder" or "Send to Mail Recipient". In my specific case, I want to
> right-click a file to "Abby Finereader -> Convert into ..." or "OmniPage
> 16 -> Convert to PDF". Fortunately, there is nothing else that these
> invoked programs require as subsequent input.
Nothing perlisch here, just create the appriopriate shortcut in the
SendTo folder.
If you really want to modify the context menu, ask in a Windows oriented
group.
HTH,
M4
> * in the file explorer, right-click on a file [whose name my perl
> program provides] and select a particular program to invoke on this
> file. For example, this could be "Send To -> Compressed (zipped)
> Folder" or "Send to Mail Recipient". In my specific case, I want to
> right-click a file to "Abby Finereader -> Convert into ..." or
> "OmniPage 16 -> Convert to PDF". Fortunately, there is nothing else
> that these invoked programs require as subsequent input.
>
> Then I want to wait until the invoked program is completed and
> exits. This is it.
As Martijn Lievaart mentioned, this isn't a Perl problem. Altering the
behaviour of the right-click menu in "Explorer" is to do with the Windows
registry. (You can alter the Windows registry via Perl but it isn't
necessary to do so to solve this problem.) The following blog post
describes how to add an Emacs command to the right click menu:
http://linuxtnt.wordpress.com/2008/03/06/
I expect you can adjust this to your problem easily.
I believe (but ICBW) that this is not what the OP is asking. I think he
is trying to *invoke* an existing right-click option on a given file.
For ordinary options (those in the first section of the menu, and those
in Send To) this is easy: just incoke the appropriate command with the
appropriate options. For those provided by dlls, this is much harder,
and I'm afraid I don't know of any easy way to do it. I would advise
checking the documentation of your OCR programs to be sure they don't
provide some sort of command-line interface.
Ben
--
All persons, living or dead, are entirely coincidental.
b...@morrow.me.uk Kurt Vonnegut
Exactly. I really want to write a sub in Perl that does exactly the
same as right-clicking by hand would achieve. Yes, these menu options
are provided by programs. (I used "Send to" as an illustration,
because everyone has seen what it is.)
In some sense, all that I need is something like
my $process = $somefilename->rightclick("OmniPage 16", "Convert to
Pdf"); # do the same thing as a hand-rightclick first on OmniPage16
and then its submenu Convert to pdf"
wait($process); # wait until it completes
That's it. Does anyone know?
/iaw
You don't need to emulate a right-click at all. All Explorer does is
execute a program or calls a DLL in the fashion specified by file extension.
Finding out how to execute the program can be easy or difficult, depending
on how it is called You can look at the file association used by windows
(In Explorer, click Tools->Folder Options->File Types. Find the select the
extension, then click the "Advanced" button. A list of "Actions" will be
displayed, select the action, and click "Edit". This will then show the
application that is executed. "%1" is the name of the selected file.
Sometimes its not this easy to figure out how windows does this, but since
no other input is required from the user when selecting the right-click menu
item, this will probably tell you which program is being executed.
Also check out the "C:\Documents and Settings\{loginname}\SendTo" directory.
This will list the "SendTo" items on the right-click menu. These will
either be a ".LNK" type or a zero byte file. If it is a link, you can see
the program associated with it by selecting it and clicking "Properties".
If it is a zero byte file, it will have a "dot" in it and the everything
after the dot is the file association. To find out how this works you will
need to some digging in the registry to figure out what program or DLL is
associated with that extension.