Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl, FIFOs, keyboard input sent to image viewer 1

Status
Not open for further replies.

phinsman

Programmer
Joined
Sep 23, 2003
Messages
6
Location
US
I'm stumped.

I'm using Linux. I want to have a simple Perl script which will accept keyboard input and send commands to an image viewer running in another window.

Here are some details:

The viewer is called viewfax. It is run from the command line as such:

viewfax /home/me/fax.tif

It pops up into its own window, and accepts keyboard commands such as these:

Z - Zoom in
z - Zoom out
u - flip page upside-down
Pg-Up - previous page in tif
Pg-Dn - next page in tif
q - quit

I have a script running where I want to control viewfax from within it. Thus I've been trying to use a named pipe and a fork to send commands to the process. The viewfax window should remain open, continuously accepting commands, until the 'q' command is sent which of course exits viewfax.

Thanks very much for any help.

Dale
 
can you run viewfax on the end of a pipe -- like this?

open(VF, '|viewfax thingy.tif');
select(VF); $|=1;
print VF 'Z';
sleep(10);
print VF 'q';
close(VF);

Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Dale,
Check out X11::GUITest on CPAN. This is a great little module that will allow you to sent X11 events (i.e. keyboard, mouse, etc.) to X11 apps. I have used it to control things like open office to convert Word docs to PDF. It should be able to do waht you are looking for.

Hope that helps.
 
Thanks to both of you for replying.

Mike, I gave that a try, but no luck there either. I've about given up on using viewfax with a pipe. It seems no matter what I do to change the STDIN, it doesn't care, and uses keyboard instead.

Usige...I downloaded X11::GUITest as you suggested and it may be just what I'm looking for! I was able to send commands to viewfax with it, by switching window focus and using SendKeys().

Thanks again, both of you.

Dale
 
Usige is quite right -- not knowing viewfax I didn't realise it was an X application.

A moments thought would have told me that viewing a tif file would *probably* need a graphics environment. Duh me.


Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top