Simple Linux/X11 programme to grab and keep the keyboard focus?

為{幸葍}努か 提交于 2019-12-11 06:48:11

问题


I am writing a simple typing break / anti-RSI programme on Linux (Ubuntu) in Python. I asked similar questions about locking the keyboard ( How do I 'lock the keyboard' to prevent any more keypresses being sent on X11/Linux/Gnome? and Releasing all keys after disabling the keyboard in X11/Linux using xinput? ) and someone suggested ( https://stackoverflow.com/a/10769704/161922 ) that grabbing the keyboard focus would be the best way. However I'm new to X11 programming. How would I do that in Python? (Presume I have python-xlib or whatever installed, I can also install anything from pypi or apt).

How do you make a simple X11 application that will grab the keyboard focus (even if another window is currently focussed). It should not be possible for the user to alt-tab or alt-f4 away from this (i.e. there is no escape). However it should be possible to 'release' this 'grabbing' later or at any time.

来源:https://stackoverflow.com/questions/10796363/simple-linux-x11-programme-to-grab-and-keep-the-keyboard-focus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!