我正在对用 C 编写的 OpenGL 应用程序进行小型验收测试。到目前为止,我只能截取屏幕截图,还没有找到在 Wayland 和 X11 上模拟鼠标和键盘输入的方法。
关于如何在 Wayland/X11 中操作特定窗口的事件流有什么建议吗?
用于模拟X11
鼠标事件你有几种选择:
- If your
X server
支持XTEST
扩展名(通常是这样),然后使用XTEST Extension Library
有功能XTestFakeKeyEvent
,XTestFakeMotionEvent
等。example https://stackoverflow.com/questions/14428438/is-there-any-general-interfaces-on-linux-to-simulate-mouse-movements-and-click
- 您可以使用
XLib
功能类似于XSendEvent
, XWarpPointer
等。example https://gist.github.com/pioz/726474
- 如果你在
Linux
并且您的测试可以访问命令 shell,那么您可以使用命令行工具xdotool
(内部使用XTEST extension
. An example http://xmodulo.com/simulate-key-press-mouse-movement-linux.html
For Wayland
您可以使用uinput
内核模块。文档和示例是here https://www.kernel.org/doc/html/v4.12/input/uinput.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)