Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I feel partly responsible for confusion and code re-writes caused by my words that "GetEvents and sleep are not required". I don't know if you indeed tried to exclude both to find timeout never occurs if user is inactive; then restored just "peeking" into the queue (GetEvents) to detrimental effect, and finally restored the original. Maybe this timeout is crucial to your application. Maybe the above never happened, it's just the (wrong) idea of

GetEvents returned just a single scalar ... would be more efficient

Maybe you tried to timeout through alarm (I think it is somewhere in FAQ) to find it doesn't work with blocking I/O on Windows. Maybe I'm partially or totally wrong, you are not interested in "things async", peeking/blocking, etc. Code finally working as desired is important (which is absolutely right!), goal achieved. Well, so it's to my amusement and sleep-not-really-OK bias I found that timed-out Win32::Console::Input can be done like this:

use strict; use warnings; use feature 'say'; use Win32::Console; use Win32::IPC 'wait_any'; use Time::HiRes 'time'; my $IN = Win32::Console-> new( STD_INPUT_HANDLE ); my $max = 15; my $count = 0; my $t = time + $max; while ( wait_any @{[ $IN ]}, 1000 * ( $t - time )) { my @ev = $IN-> Input; say "Ah ah ah, you didn't press the magic key <--- @ev"; ++ $count } say $count ? "Enough, I'm tired! $count events in $max seconds!" : "You failed to press ANY key in $max seconds! Read my FAX!!!";

In reply to Re^2: Unable to capture mouse events in Win32::Console by vr
in thread Unable to capture mouse events in Win32::Console by fireblood

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 21:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found