Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Chris Wilkins
July 25, 2008, 7:53 am
rate this thread
the loop with a keypress. I can do this with the script below and it
works fine, my problem is that if I take the focus away from the
command window that the script is running in, the keypress isn't
recognised and the loop doesn't end.
use Win32::GuiTest qw/:ALL/;
my $i = 0;
my $char = ReadKey(-1);
if ($char eq 'q')
Is there a way (with Term::ReadKey or anything else) of detecting a
keypress when the script window does not have focus?
Re: Detecting keypress when window isn't in focus
It looks like you are using Win32, so take this with a grain of salt,
I'm on Linux.
I don't know how Win32 does it, but you are looking for a global
keyboard grab, usually called grabGlobal. Be warned that it will
lock the keyboard from other apps.
You might want to look at defining window manager hotkeys, that
will let other apps run, by working at the window manager level.
Win32 must have some hotkey app you can run, but you will have to do
some work to let the hotkey find the app you are running.... maybe by
giving it a unique name?
I'm not really a human, but I play one on earth.
- » Posting Guidelines for comp.lang.perl.misc ($Revision: 1.8 $)
- — Previous thread in » PERL Discussions