Re: Creating keybinds GLOBALY!
by anonymized user 468275 (Curate) on Aug 04, 2005 at 07:47 UTC
|
Setting up Tk event callbacks, including key pressing events are explained thoroughly in the chapter 'Anatomy of the main loop' of O'Reilly's 'Mastering perl/Tk'. ISBN 1565927168Update: the chapter is available on line: http://www.oreilly.com/catalog/mastperltk/chapter/ch15.html - to find the relevant section keystroke events come under the event class of 'window events'
| [reply] |
|
|
Ah, yes. That binding I know of... However, it doesnt work when window is out of focus... (as I recall)
| [reply] |
|
|
If the window is out of focus, Windows will deliver the keystrokes to whichever application it considers to be in focus. That fact has nothing to do at all with whatever perl method you use to capture the keystrokes. In fact that behaviour is user-configurable under linux and windows and is therefore entirely beyond the power of the programmer (unless you hack the O/S and invent your personal GUI paradigm).
| [reply] |
|
|
| [reply] |
Re: Creating keybinds GLOBALY!
by Anonymous Monk on Aug 04, 2005 at 05:57 UTC
|
| [reply] |
|
|
Hmm, that is more logging all keys.. I want it to react just on... say.. CTRL+P.
| [reply] |
Re: Creating keybinds GLOBALY!
by davis (Vicar) on Aug 04, 2005 at 08:41 UTC
|
You want to run a specific task when you press a specific key? I'd use AutoHotkey
Update: Fixed URL.
davis
Kids, you tried your hardest, and you failed miserably. The lesson is: Never try.
| [reply] |
|
|
That url gets me to microsoft.com...
Anyway, I want it in perl... Say we got this simple thing:
use Tk;
my $main = new MainWindow(-title => "Global Testing");
$main->bind("<KeyPress>", sub {print "Hello there!"});
MainLoop;
Now, the binding doesnt work when window is out of focus... (as someone said is impossible to make working in tk in some other thread here at PerlMonks...) | [reply] [d/l] |
|
|
Anyway, I want it in perl...
I really have to ask... why?
You can make AutoHotkey run any abitrary program. I've used it to launch perl scripts, .bat scripts, etc. And yes, you're correct, you can't use Tk to bind a keypress when the window's out of focus. (At least, not that I know of)
davis
Kids, you tried your hardest, and you failed miserably. The lesson is: Never try.
| [reply] |
|
|
|
|
|
|
|
| [reply] |