Disabling / Redirecting a Keyboard in Python

I am writing a macro generator / keyboard remapper in python, for xubuntu.

I figured out how to intercept and record keystrokes, and send keystrokes that I want to record, but I did not understand how to block keystrokes. I need to disable keyboard input to reassign the key. For example, if I wanted to send "a" when I press the "s" key, I can record "a" the keystroke and set it to play when I press the "s" key. I cannot, however, hold down the s key next to it.

I used the pyxhook module from open-source key-logger for interceptors and another false input method from the python x library.

I remember reading somewhere that someone was blocking all keyboard input, redirecting all keystrokes to an invisible window using tkinter. If someone can post this method, that would be great.

I need something that will block all keystrokes, but not turn off my keyboard hooks.

+3
source share
2 answers

I think this will be highly dependent on the environment: curses and the activestate recipe are good for the command line, but if you want it to work in DE, you will need some hooks for this DE. You can look at Qt or GTK bindings for python or create a python-xlib library that could link you directly to the X system.

, " ". noecho, DE xmodmap- ?

+1

, X. , . , , . , Python Xlib, .

0

Source: https://habr.com/ru/post/1709892/


All Articles