将程序化的鼠标事件发送到X [英] Sending Programmatic Mouse Events to X
问题描述
我对Linux上的X
开发有些陌生.我想知道以编程方式发送游标事件的最佳做法(或指向资源的链接)是什么.将光标移动到规范化(X,Y),创建鼠标左右键等.理想情况下,这将是C/C++
中的内容.
I am somewhat new to X
development on Linux. I'm wondering what are best practices (or links to resources) for programmatically sending cursor events. Moving the cursor to a normalized (X,Y), creating right/left mouse clicks, etc. Ideally this would be something in C/C++
.
我玩过Qt QCursor
,但我想知道完成此操作的原始方法.
I have played around with the Qt QCursor
but I'd like to know the raw way to accomplish this.
推荐答案
我认为您可以使用 XSendEvent
.在此处中有一些示例代码使用 XQueryPointer
填充大多数事件字段.
I think you can use XSendEvent
. There's some sample code here which uses XQueryPointer
to populate most of the event fields.
如果只想移动指针,请使用 XWarpPointer
.
If you just want to move the pointer, use XWarpPointer
.
这篇关于将程序化的鼠标事件发送到X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!