每次按下一个键时是否回调函数(无论哪个窗口具有焦点)? [英] A function callback every time a key is pressed (regardless of which window has focus)?

查看:106
本文介绍了每次按下一个键时是否回调函数(无论哪个窗口具有焦点)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Linux(Ubuntu Linux 9.10)上编写一个程序(用python),该程序将跟踪我每秒产生的每秒钟按键次数.其中包括普通字母键,以及控制/Shift/空格/等.

I want to write a programme (in python) on Linux (Ubuntu Linux 9.10) that will keep track of how many key presses per second/minute I make. This includes normal letter keys, and control/shift/space/etc.

是否有某种方法可以挂接到X,以便我可以说按下键时调用此函数?".由于我希望在正常工作时在后台运行此功能,因此此函数调用必须能够知道所有程序的所有按键.我想这有点像键盘记录器.

Is there some way to hook into X so that I can say "when a key is pressed call this function?". Since I want to have this running in the background while I work normally, this function call will have to be able to be aware of all key presses for all programmes. I suppose it's a bit like a keylogger.

这只是个人的事情,所以我不在乎使其在Windows/OSX上运行,也不在乎人们何时会使用远程X会话等.

This is only a personal thing, so I don't care about making it work on Windows/OSX, and I don't care about when people have fancy remote X sessions etc.

推荐答案

看看其他人已经做了什么.您可以看看 pykeylogger 代码如何在其

Take a look at what others have done already. You can take a look on how this pykeylogger code handles Linux in its backend, and see if that works for you.

这篇关于每次按下一个键时是否回调函数(无论哪个窗口具有焦点)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆