tags:

views:

585

answers:

2

I was wondering if there were equivalents of the above mentioned functions for Linux (X11) - I can't seem to find them.

A: 

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.

ypnos
+1  A: 

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.

asveikau