473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 4589
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: willem | last post by:
Hi, I want move my form with mouse when I press button over a different position from normal bar of title. I set MouseUp, MouseDown and, MouseMove events and all works good. is it...
0
by: Sam Sungshik Kong | last post by:
Hello! If I understand correctly, MouseMove event is triggered when the mouse moves (ie when point changes). I, however, found out that it's triggered even if the mouse is not moving. What I...
3
by: Just Me | last post by:
If I move the mouse cursor over a control and stop moving I get a MouseHover event. If I then move the cursor while staying within the control and then stop moving I do not get another...
2
by: Carl Gilbert | last post by:
Hi I have a math kinda problem where I'm trying to split some lines when two or more lines connect two shapes. The reason I am doing this is to make it clear that there are multiple lines...
3
by: b747_440 | last post by:
Hello Newsgroup, I try to resize and move a picturebox. However, after each operation the picture box is being redrawn. This causes flickering. Is it possible to suppress the first redraw and draw...
0
by: Ginger Estherskip | last post by:
How do you programmatically start moving a SDI winform? Here's the issue: I've got a form as part of a tabbed MDI set, and I wrote it so that a user can "tear" the form off of the MDI by...
0
by: =?Utf-8?B?QW5kcmV3?= | last post by:
I have 6 small touch screens that are connected to my pc to a special video card. The video driver splits up my screen in six sections, 3 across the top and 3 across the bottom. They are all even...
10
by: cjparis | last post by:
Hello everyone. If anyone can give me a hand I would be gratefull Am doing a site which requires a moving element and have used DHTML to do it. Have a simple Browser detect script to sort IE...
0
by: Studlyami | last post by:
I am trying to find how windows translate the input from a HID device to an actual windows message; specifically, the mouse. I am trying to figure out how when the mouse moves the process windows...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.