468,513 Members | 979 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

C++ and moving the mouse...

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?
--
Narcolessico
http://binaryunit.blogspot.com
Feb 29 '08 #1
1 4101
Narcolessico wrote:
[..]
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?
Tips on Xlib and Qt are off-topic, sorry. Here we talk C++ language
itself, which incidentally does not define any ways to control mouse
or any other hardware for that matter. Try the newsgroup for your OS.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Feb 29 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by willem | last post: by
reply views Thread by Sam Sungshik Kong | last post: by
2 posts views Thread by Carl Gilbert | last post: by
reply views Thread by Ginger Estherskip | last post: by
10 posts views Thread by cjparis | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.