开发者

Python Keyboard shortcuts

So, I have a python script running I the background, and I want 开发者_如何学Goit to trigger X function whenever a key combination is pressed. How would I implement that? The problem is that the app will be running in the background, so it won't have focus from the OS.


Well, it basicly has nothing to do with python. That heavily depends on the operating system you're working on.

You can use XLib under Linux (http://python-xlib.sourceforge.net/) or wxPython under Windows (http://wxpython.org/docs/api/wx.Window-class.html#RegisterHotKey)

Another idea would be to hook the system keyboard events (through pyHook) and try to catch any hotkeys.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜