I'm trying to write a simple macro program to record and playback user input (keystrokes, mouse movements and button clicks). I'm having trouble reading keystrokes and button clicks that are not in the perl window. Specifically, I'd like to run the perl progam from a command prompt, then move over to another window (losing focus on the command prompt), but still read the mouse movements, button clicks, and keystrokes. I plan to run this on a Win32 XP box, so my target modules are either Win32::GUI or PerlTk.
Here's what I've discovered so far:
Win32::GUI::GetCursorPos works great for reading the location of the mouse at the root level, regardless of which window has the focus.
There doesn't seem to be a way to read keystroke events in Win32::GUI.
I've avoided using Term:ReadKey, as this module says it won't work in a Windows environment.
Term::Getch works okay, but it won't work once focus is lost from the execution window. Also, it only returns ASCII characters, so it can't read function keys.
PerlTK has a nice binding interface for recognizing keystrokes and mouse button presses, but it only works when the Tk main window has focus.
Win32::GuiTest works great for simulating mouse movement and button presses, and does not require focus.
Can anyone recommend a technique for reading user input when focus is lost?