D
Dilbert
I have a perl program (under windows vista) that records every
scancode / keystroke I make (it even records when I hit the Ctrl-key,
the Shift-key, F1, F2, etc....
So the program works ok for me, but it has a "do{...}until" loop that
better should be replaced by a sleep command. My concern is that I
waste a lot of CPU cycles in the do{...}until loop, that could be
avoided if I replace that loop by a sleep command
How can I achieve this ? does such a command exist under windows ?
(just in case you might ask: I already tried each and every option in
Term::Readkey, it definitely does not record when I hit the Ctrl-key,
Shift-key, etc...) Fortunately, Win32::Console does the job quite
well, it is just the do{...}until loop that bothers me because it
wastes CPU cycles.
Here is the program:
use strict;
use warnings;
use Win32::Console;
my $CONS_INP = Win32::Console->new(STD_INPUT_HANDLE);
while (1) {
# I want to sleep here until a key is pressed...
# How can I achieve this under Windows... ???
my @event;
do {
@event = $CONS_INP->Input() if $CONS_INP->GetEvents();
} until @event;
local $" = "', '";
print "event = ('@event')\n";
last if $event[5] == 27; # Escape key
}
Is there a perl module for windows that allows me to sleep (or wait ?)
until a key is pressed (even if it is the Ctrl-key, or the Shift-key)
scancode / keystroke I make (it even records when I hit the Ctrl-key,
the Shift-key, F1, F2, etc....
So the program works ok for me, but it has a "do{...}until" loop that
better should be replaced by a sleep command. My concern is that I
waste a lot of CPU cycles in the do{...}until loop, that could be
avoided if I replace that loop by a sleep command
How can I achieve this ? does such a command exist under windows ?
(just in case you might ask: I already tried each and every option in
Term::Readkey, it definitely does not record when I hit the Ctrl-key,
Shift-key, etc...) Fortunately, Win32::Console does the job quite
well, it is just the do{...}until loop that bothers me because it
wastes CPU cycles.
Here is the program:
use strict;
use warnings;
use Win32::Console;
my $CONS_INP = Win32::Console->new(STD_INPUT_HANDLE);
while (1) {
# I want to sleep here until a key is pressed...
# How can I achieve this under Windows... ???
my @event;
do {
@event = $CONS_INP->Input() if $CONS_INP->GetEvents();
} until @event;
local $" = "', '";
print "event = ('@event')\n";
last if $event[5] == 27; # Escape key
}
Is there a perl module for windows that allows me to sleep (or wait ?)
until a key is pressed (even if it is the Ctrl-key, or the Shift-key)