Solved

A working example of mouse movements?

Posted on 2006-11-07
2
961 Views
Last Modified: 2012-06-21
I've tried looking on the web for turorials on how to move my mouse cursor to a certain location and then simulate a clicking.  Much like the macro programs you can download.  I myself want to create my own macro, but instead of downloading a program, i'd like to do it myself for the learning experience.

Is there anyone here that could give me a fully working example in C++ (start to finish) that takes the mouse cursor and moves it to xxx, yyy coordinates and then simulate it double clicking?  I learn the best when I can see an example script :(  Sorry if its too much to ask, sounds relativelty simple I suppose.

Thanks, I use bloodshed c++ compiler.

0
Comment
Question by:Whipsmack
[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
2 Comments
 
LVL 12

Accepted Solution

by:
rajeev_devin earned 140 total points
ID: 17895339
>> Is there anyone here that could give me a fully working example in C++
You won't find any such API to do so in C++.
As these type of things are platform dependent.
 
In windows you have these functions

VOID mouse_event(
  DWORD dwFlags,         // motion and click options
  DWORD dx,              // horizontal position or change
  DWORD dy,              // vertical position or change
  DWORD dwData,          // wheel movement
  ULONG_PTR dwExtraInfo  // application-defined information
);

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/mouseinput/mouseinputreference/mouseinputfunctions/mouse_event.asp


UINT SendInput(
  UINT nInputs,     // count of input events
  LPINPUT pInputs,  // array of input events
  int cbSize        // size of structure
);

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/sendinput.asp
0
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 17895344
If you are in windows platform then you can use these two function in bloodshed c++ compiler.
0

Featured Post

Independent Software Vendors: 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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

730 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