Generate keystrokes in Linux from Python3

筅森魡賤 提交于 2019-12-24 11:37:32

问题


I need to generate keystrokes in Linux (Raspbian) from Python3. Something like uinput but for Python3. I'd prefer not to use subprocess for this.

Easier to install (apt-get) the better as it will be used in a guide to show others.

Any ideas? Thomas


回答1:


Found PyUserInput that works.

https://github.com/SavinaRoja/PyUserInput/wiki/Installation https://github.com/SavinaRoja/PyUserInput

sudo apt-get install python3-pip
sudo pip-3.2 install python3-xlib
sudo pip-3.2 install PyUserInput

And the Python:

from pykeyboard import PyKeyboard
keyboard = PyKeyboard()
keyboard.tap_key("a")


来源:https://stackoverflow.com/questions/32536270/generate-keystrokes-in-linux-from-python3

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