Hey guys,

We're trying to work with a driver program for our robot. If we can grab the x and y coordinates of the Mouse we could send them to the controller for driving. Does anyone know how to capture the mouse movement into an integer?

maybe:
http://www.daniweb.com/forums/thread67435.html

#include <windows.h>
#include <iostream>
using namespace std;

int main()
{ 
  while ( 1 )
  {
    Sleep ( 500 );
    POINT pos;
    GetCursorPos ( &pos );
// here is your coordinates
    int x = pos.x;
    int y = pos.y;

    cout << "x pos:" << x << endl;
    cout << "y pos:" << y << endl << endl;
  } 
  return 0;
}

my output

x pos:377
y pos:272

x pos:377
y pos:272

x pos:377
y pos:272

x pos:585
y pos:380

x pos:360
y pos:142

x pos:379
y pos:161

x pos:424
y pos:271

x pos:424
y pos:271

x pos:488
y pos:302

x pos:502
y pos:323

x pos:502
y pos:323

I don't know about visual c++ but the above seems to work in dev-cpp I think.

This article has been dead for over six months. Start a new discussion instead.