Solved

mouseclick windows sdk

Posted on 2007-11-27
3
252 Views
Last Modified: 2010-05-18
http://msdn2.microsoft.com/en-us/library/ms648390.aspx


mouse_event(MOUSEEVENTF_LEFTDOWN,   x, y, 0, 0); // Left Key Down
mouse_event(MOUSEEVENTF_UP,   x, y, 0, 0); // Left Key UP


I just want to click the mouse, is it possible to not having getcursorpos first and then put it in?

http://www.experts-exchange.com/Programming/Languages/CPP/Q_22986461.html
0
Comment
Question by:Troudeloup
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
SeanDurkin earned 500 total points
ID: 20362690
Is this what you mean? This should click the mouse wherever it is, but you have to set the MOUSEEVENTF_ABSOLUTE flag to make sure it clicks the current mouse position, instead of the x and y relative to it.
POINT point;
GetCursorPos(&point);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,  point.x, point.y, 0, 0);
mouse_event(MOUSEEVENTF_UP | MOUSEEVENTF_ABSOLUTE, point.x, point.y, 0, 0);

Open in new window

0
 

Author Comment

by:Troudeloup
ID: 20362699
yeah, this is what I was afraid of. but it works :D
0
 

Author Closing Comment

by:Troudeloup
ID: 31411324
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question