C++ and moving the mouse...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Narcolessico

    #1

    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
    ...and weightness of meaning. Bits - these so simple entities - have the power to completely change a meaning, and a life. This is a personal blog about informatics, with "bits" of other things.

  • Victor Bazarov

    #2
    Re: C++ and moving the mouse...

    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


    Comment

    Working...