Solved

A working example of mouse movements?

Posted on 2006-11-07
2
959 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
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 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.

810 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