Solved

mouseclick windows sdk

Posted on 2007-11-27
3
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

710 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