N
Narcolessico
Hi,
I'm writing on Linux an application which needs to move the mouse pointer
and simulate button clicks (better: button press and release events
separately, e.g. to do drag&drop).
I found several ways to move the pointer:
- Using QT QCursor::setPos
- Using SDL libraries
....
- Using XLib directly
Now the problem is... I can move it, but I can't really simulate clicks.
On Qt, I don't know to who I should send the mouse motion event ( I tried to
send it to the application itself, but it doesn't work), because I don't
have any interface (it is a command line app).
With Xlib, I can move the cursor with XWarpPointer, but it seems to reset
the button state. I send a button press event with the code I found here:
http://snippets.dzone.com/posts/show/2750
but as soon as I call XWarpPointer, the button status is reset and the click
results in only a point. If a drawing application has the focus, I would
draw on it; unfortunately, I only see points.
I also tried to send XMotionEvents instead insted of using XWarpPointer, but
nothing changes. I tried to create new events each request (instead of
using the same pointer), and to call XFlush and XSync after each request...
But I can see only points.
How can I simulate a mouse motion by keeping the mouse button pressed in
C++? Which library shall I use? Any tip for Xlib or QT?
I'm writing on Linux an application which needs to move the mouse pointer
and simulate button clicks (better: button press and release events
separately, e.g. to do drag&drop).
I found several ways to move the pointer:
- Using QT QCursor::setPos
- Using SDL libraries
....
- Using XLib directly
Now the problem is... I can move it, but I can't really simulate clicks.
On Qt, I don't know to who I should send the mouse motion event ( I tried to
send it to the application itself, but it doesn't work), because I don't
have any interface (it is a command line app).
With Xlib, I can move the cursor with XWarpPointer, but it seems to reset
the button state. I send a button press event with the code I found here:
http://snippets.dzone.com/posts/show/2750
but as soon as I call XWarpPointer, the button status is reset and the click
results in only a point. If a drawing application has the focus, I would
draw on it; unfortunately, I only see points.
I also tried to send XMotionEvents instead insted of using XWarpPointer, but
nothing changes. I tried to create new events each request (instead of
using the same pointer), and to call XFlush and XSync after each request...
But I can see only points.
How can I simulate a mouse motion by keeping the mouse button pressed in
C++? Which library shall I use? Any tip for Xlib or QT?