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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Function Keys withing Perl Script

Status
Not open for further replies.

TSch

Technical User
Jul 12, 2001
557
DE
Hi folks,

I was wondering. How can I "simulate" a certain Function Key (F1, F2, F3, etc.) is being pressed within a perl script ?

Regards,
Thomas
 
The idea was the following:

There's a department using a certain client software. The client is constantly receiving data and if you want the data to be "saved" you'll have to press F8 key every time you want it to be "saved".

Because this is quite unnerving and the client software does not provide an automatism for this case I thought it could help to write a little perl script that automatically "presses" the F8 key for us every few seconds or so.

Regards,
Thomas
 
You don't say what type of OS you're software is running on, but if it's windows, I'd suggest taking a look at this module:

cpan Win32::GuiTest

- Miller
 
I'll put in another vote for Win32::GuiTest, I've used it for automation and it seemed to be the best option.

But... The application that you're controlling has to be brought to the foreground as if you were hitting F8 manually. (GuiTest can do this programatically) I had to use Win32::API to block keyboard and mouse input from the user so they couldn't change focus to another window, or the keypress would go to the new window.
I think this will probably become a problem if you have to do it every few seconds while someone is using the computer.
There could be another way to do it without bringing the window to the foreground, I don't really know. I did this quite a few years ago. At that time, I think there was a yahoo group for questions/support, and I got a lot of help there.
I can post some code if you decide to go this route
 
I think AutoHotkey would be a much simpler way to achieve this than perl. It rocks.

I use it to work around the brainless UI design in some software I am forced to use.

Annihilannic.
 
Folks,

thanks a lot for all the input !
Sounds good. I'm going to check it out.
 
AutoHotKey looks really cool.. I've already thought of a few uses for it. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top