Do you mean something like this? I'm not sure I completely understand what you want to achieve.

use Tk; my $mw = MainWindow->new; $mw->bind('<KeyPress>', \&keyPress); $mw->withdraw; my ($lastX, $lastY); $mw->repeat(400, [\&checkMouse, \$lastX, \$lastY]); $mw->focusForce; MainLoop; sub quit { print "User triggered event -- exiting!\n"; exit; } sub checkMouse { my ($lastX, $lastY) = @_; my $x = $mw->pointerx; my $y = $mw->pointery; $$lastX = $x unless defined $$lastX; $$lastY = $y unless defined $$lastY; quit() if $x != $$lastX; quit() if $y != $$lastY; } sub keyPress { quit(); }

Other ideas... if you're using X-Windows, you might have a look at X11-IdleTime, you could call that from the repeat sub. You might also tie something in to your screensaver hook, so that it pops open a window, displays it and acts as a kind of an alert asking the user if he wants to keep the user session.

You'll probably want to build some sort of timer in case the user does nothing, and allow the session to die. I'm generally pretty leery about hacks designed to keep user sessions open. of thing. Having sessions expire is a good thing, although if that session time is too short, then it can be irritating. Too long, and it can effectively be a memory leak.

Rob

In reply to Re: Perl/Tk: Is there a way to key off of any user input event? by rcseege
in thread Perl/Tk: Is there a way to key off of any user input event? by Argel

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.