Mejore el codigo que habia echo y queria dejar aqui el código por si le sirve a alguien.
Aun falta mejorar muchas pero de momento funciona.
Lo que hace el programa es grabar los movimientos del raton y guardarlo en un log.
#include <windows.h>
#include <iostream>
#include <conio.h>
#include <fstream>
#include <list>
#include <string>
using namespace std;
int main(int argc,char* argv)
{
POINT cursorPos;
GetCursorPos(&cursorPos);
int x = 0;
x = cursorPos.x;
int y = 0;
y = cursorPos.y;
int a=0;
int xx[1000];
int yy[1000];
char str[256];
int lat=0, time=0;
float lat2=0, tlat = 0, buc=0;
/*while ("") {
GetCursorPos(&cursorPos);
x = cursorPos.x;
y = cursorPos.y;
Sleep(500);
system("CLS");
cout << x << " , " << y;
}*/
cout << "OPCIONES" << endl;
cout << "1.Grabar y reproducirlo al instante" << endl << "2.Grabar y guardarlo en un archivo" << endl << "3.Abrir archivo"<< endl ;
int o;
cin >> o;
cout << endl << endl <<"Latencia (normal 50):: ";
cin >> lat2;
lat=int(lat2);
cout << endl << endl << "Duracion en segundos:: ";
cin >> time;
tlat=lat2/1000;
buc=time/tlat;
buc=int(buc);
if (o==2) {
system("CLS");
cout << "Nombre del archivo:: ";
cin.get();
cin.getline (str,256);
ofstream outfile (str,ofstream::binary);
a=0;
system ("CLS");
cout << "Faltan 10 segundos para que comienze a reproducirse.";
system ("CHOICE /T 10 /C ync /CS /D y > nul");
cout << endl << "COMENZANDO A GRABAR";
while (a!=buc) {
xx[a]=x;
yy[a]=y;
GetCursorPos(&cursorPos);
x = cursorPos.x;
y = cursorPos.y;
Sleep(lat);
a++;
}
a=0;
cout << endl << endl << "GUARDANDO";
while (a!=buc) {
cout << xx[a] << "," << yy[a] << ";" << endl;
outfile << xx[a] << "," << yy[a];
if (a+1==buc) {
outfile << ";" << "::::";
} else {
outfile << ";" << endl;
}
a++;
}
cout << endl << "GUARDADO FINALIZADO";
} else if (o==1) {
system("CLS");
a=0;
while (a!=buc) {
xx[a]=x;
yy[a]=y;
GetCursorPos(&cursorPos);
x = cursorPos.x;
y = cursorPos.y;
Sleep(lat);
a++;
}
a=0;
while (a!=buc){
SetCursorPos(xx[a], yy[a]);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, GetMessageExtraInfo());
Sleep(lat);
a++;
}
} else if (o==3) {
system("CLS");
cout << "Nombre del archivo: ";
cin.get();
cin.getline (str,256);
ifstream arc;
arc.open (str);
char c;
a=0;
string s="";
int posx, posy;
system ("CLS");
cout << "Faltan 10 segundos para que comienze a reproducirse.";
system ("CHOICE /T 10 /C ync /CS /D y > nul");
int i=0;;
while (c!=':')
{
s="";
cout << c;
while ((c!=',')&&(i==0)){
c = arc.get();
s = s + c;
}
i=1;
posx=atoi(s.c_str());
s="";
while ((c!=';')&&(i==1)){
c = arc.get();
s = s + c;
}
if (c==';') {
c = arc.get();
}
i=0;
posy=atoi(s.c_str());
xx[a]=posx;
yy[a]=posy;
a++;
}
int aa=a;
a=0;
while (a!=aa) {
Sleep(lat);
SetCursorPos(xx[a], yy[a]);
a++;
}
}
}