开发者

Windows API function equivalents (SetCursorPos, GetCursorPos, mouse_event, keybd_event ...) for Linux (X11)?

I was wondering if there were equivalents of the above mentioned functions for Linux (X11) - I can't see开发者_JS百科m to find them.


The Xlib functions you want are XQueryPointer() and XWarpPointer().

I've had issues with these not always returning what one would expect. The XTest extension as mentioned above was able to suit my needs. In particular the library function XTestFakeRelativeMotionEvent() worked well for what I was doing. YMMV.


Letting GetCursorPos apart, what you essentially want to do here is to emulate user input, like motion of the mouse pointer to a given location, or mouse button/keyboard input.

This is not part of the standard X11 API. However, the XTest extension provides this functionality and it should come with every decent X11 implementation out there. Another possibility may be the XTrap extension.

Here is the reference of XTest: X11 XTEST EXTENSION (PDF)

For GetCursorPos, I don't know of a simple equivalent right now (although I assume it is there). What you can always do, however, is to process motion events, which will tell you where the pointer was moved to, whenever it is moved.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜