Solved

mouseclick windows sdk

Posted on 2007-11-27
3
243 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
Comment Utility
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
Comment Utility
yeah, this is what I was afraid of. but it works :D
0
 

Author Closing Comment

by:Troudeloup
Comment Utility
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

772 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

14 Experts available now in Live!

Get 1:1 Help Now