Simulate Mouse Move

Please support our C++ advertiser: Intel Parallel Studio Home
Closed Thread

Join Date: Aug 2004
Posts: 2
Reputation: Thalandor is an unknown quantity at this point 
Solved Threads: 0
Thalandor Thalandor is offline Offline
Newbie Poster

Re: Simulate Mouse Move

 
0
  #11
Aug 23rd, 2004
could sum1 post stdafx.h please, thanks
Quick reply to this message  
Join Date: Aug 2004
Posts: 2
Reputation: Thalandor is an unknown quantity at this point 
Solved Threads: 0
Thalandor Thalandor is offline Offline
Newbie Poster

Re: Simulate Mouse Move

 
0
  #12
Aug 23rd, 2004
  1. #include "windows.h"
  2. int main(int argc, char* argv[]){
  3. INPUT *buffer = new INPUT[3]; //allocate a buffer
  4. int X = 30;
  5. int Y = 50;
  6. SetCursorPos(X,Y);
  7.  
  8. mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP,
  9. X,
  10. Y,
  11. 0,
  12. 0
  13. );
  14. return 0;
  15. }

that works just fine
Quick reply to this message  
Join Date: Feb 2005
Posts: 2
Reputation: littlewater is an unknown quantity at this point 
Solved Threads: 0
littlewater littlewater is offline Offline
Newbie Poster

Re: Simulate Mouse Move

 
0
  #13
Feb 16th, 2005
ENNN

but there are the param mi.dx and mi.dy what is their function?

maybe there is something else ...

but I haven't found it now ... : :rolleyes:
Quick reply to this message  
Join Date: Sep 2004
Posts: 7,783
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 745
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Simulate Mouse Move

 
0
  #14
Feb 16th, 2005
You realize that this thread has been inactive for several months, yes?
I'm here to prove you wrong.
Quick reply to this message  
Join Date: Mar 2007
Posts: 1
Reputation: clrcbird451 is an unknown quantity at this point 
Solved Threads: 0
clrcbird451 clrcbird451 is offline Offline
Newbie Poster

Re: Simulate Mouse Move

 
0
  #15
Mar 5th, 2007
I have used windows.h to move my cursor to a specific pixel on the screen. I do not know what type of style you are programming in because I only got errors with the cod you gave me but I do know that the code below works in a “Win32 Console application”. I have come across many automated mouse & keyboard artificial event simulators in c++, but all I came across that I could maintain is a few keyboard buttons and to move the mouse. Even though my main voyage was to purely get the mouse to click as fast is can for one of the games I have, I hope will help on your attempt to (as for why you want it to click at 100,100 is very strange to me).
As:
#include <iostream>
//#include<iostream.h>
//my compiler looks for iostream without “.h”, you may need to add
//it in as you copy this
#include <windows.h>
#include <conio.h>
//for getch() to pause at the end

usingnamespace std;

void main()
{
//get the position of cursor first
cout<<"pos before change"<<endl;
POINT pos;
GetCursorPos(&pos);
int x=pos.x;
int y=pos.y;
Sleep(10);
cout<<"x:"<<x<<", "<<"y:"<<y<<endl;
cout<<"pos set to 100,100"<<endl;
//MOVEMENT HERE \/\/\/
SetCursorPos(100,100);
//get cursor pos again
GetCursorPos(&pos);
x=pos.x;
y=pos.y;
Sleep(10);
cout<<"x:"<<x<<", "<<"y:"<<y<<endl;
cout<<"pos set set to x+1,y-1 (if mouse not moving, it should be 101,99)"<<endl;
//set again();
GetCursorPos(&pos);
x=pos.x;
y=pos.y;
SetCursorPos(x+1,y-1);
//read for the last time
GetCursorPos(&pos);
x=pos.x;
y=pos.y;
Sleep(10);
cout<<"x:"<<x<<", "<<"y:"<<y<<endl;
cout<<"press any key to exit";
getch();
}
Quick reply to this message  
Join Date: Sep 2004
Posts: 7,783
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 745
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Simulate Mouse Move

 
0
  #16
Mar 5th, 2007
You realize that this thread has been inactive for several years, yes? :rolleyes:
I'm here to prove you wrong.
Quick reply to this message  
Join Date: Jun 2007
Posts: 1
Reputation: uglinho is an unknown quantity at this point 
Solved Threads: 0
uglinho uglinho is offline Offline
Newbie Poster

Re: Simulate Mouse Move

 
0
  #17
Jun 8th, 2007
Hello guys, can any one here compile this source code, make a exe file and upload for some newbees guys like me? have a nice day all of you!
Quick reply to this message  
Closed Thread

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC