Solved

A working example of mouse movements?

Posted on 2006-11-07
2
958 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
  • 2
2 Comments
 
LVL 12

Accepted Solution

by:
rajeev_devin earned 140 total points
Comment Utility
>> 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
Comment Utility
If you are in windows platform then you can use these two function in bloodshed c++ compiler.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

728 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

10 Experts available now in Live!

Get 1:1 Help Now