[Tutor] Print Screen
Luke Paireepinart
rabidpoobear at gmail.com
Fri Nov 3 03:36:18 CET 2006
>> Anyone know of a way to capture special keys like "Print Screen"?
>> I have a small script to grab all they keycodes, but it doesn't seem to
>> catch several keys on the keyboard. I've got a utility that I'd like to
>> be able to automagically get a screenshot when something goes wrong so I
>> dont have to hope the user can re-create the error. Universal support
>> would be best, but WinXP is the main OS
>>
>>
>
> I'm not exactly sure what you want here :-) but if you want to capture
> when the 'Print Screen' key (or any other key) has actually been
> pressed, try pyHook. Note: pyHook only works on Windows!
>
Also note that if you want all of the keypresses, but you _don't_ care
about the application with focus
receiving the input, you can do a complete key grab using TKInter or
Pygame, and probably the other GUI packages too.
But, like I said, if you were, for example, typing an e-mail and you
started a script that did a complete grab like this, you'd no longer be
able to type
into the e-mail window. Using pyHook, your program could see all the
keypresses, but they'd also still be sent to the e-mail program.
Actually, I've never tried it, but I'm pretty sure that's how the GUI
packages' key capturing works.
You may be asking 'well, it sounds like pyHook does a better job of this
anyway!'
Yeah, you're right.
However, as Alan exclaimed, pyHook works only on Windows!
So the solution I offered would be more portable.
Hope that helps,
-Luke
More information about the Tutor
mailing list