How to create a global hotkey?
Jonathan Curran
jonc at icicled.net
Fri Dec 8 23:33:09 EST 2006
On Thursday 07 December 2006 05:53, k04jg02 at gmail.com wrote:
> I want to make a Python app that runs in the background, and when a
> user hits a key combination, for a function to run. This sounds simple
> enough, but all of the keypress detecting libraries I can find count on
> you creating a window and then detecting keypresses while that window
> has focus. I want my function to execute when the user presses the
> hotkey anywhere. I searched the PyGTK documentation and found an old
> newsgroup post where someone mentioned the C GTK+ library has it but
> PyGTK does not, PyQT showed no results, not sure where else I should
> look. I'd be willing to use a library that isn't a windowing toolkit --
> I just want to be able to be able to globally detect a keypress. Any
> ideas?
A little bit of googling revealed:
XGrabKey: http://tronche.com/gui/x/xlib/input/XGrabKey.html
Example: http://tigerdyr.wheel.dk/ctwm-archive/1328.html
It's done here in C, hopefully you can do the same with the python module for
xlib that was mentioned earlier.
- Jonathan
Google = best friend
More information about the Python-list
mailing list