in reply to Perl/Tk: Is there a way to key off of any user input event?

Since you are using this as a screensaver type app, and you want it to have focus when it's out of the mainwindow, you may want a grab_global call. Try this. I've included an 'Escape' key to quit, but you could use a password. You could also make it full screen and put a graphic on it.
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new; #my $width = $mw->screenwidth; #my $height = $mw->screenheight; #$mw->geometry($width . 'x' . $height .'+0+0'); $mw->bind('<Motion>', [\&activity ,'mouse']); $mw->bind('<Key>', [ \&activity, Ev('K')]); $mw->after(500,sub {$mw->grabGlobal}); #window must be visible $mw->focusForce; #for grab MainLoop; sub activity { if( $_[1] eq 'Escape'){ exit } print chr(07); #beep }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^2: Perl/Tk: Is there a way to key off of any user input event?
by Argel (Prior) on Oct 17, 2006 at 01:07 UTC
    Thanks zentara, the grabGlobal was the last thing I needed!! And thanks to everyone for the help!! My users will love you!! :-)