Solved

mouseclick windows sdk

Posted on 2007-11-27
3
245 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now