Log in

View Full Version : Track Mouse Speed



massive630
09-24-2010, 12:19 AM
im working on a script that will track my mouse movement speed from the pixel I start moving on, to the pixel i stop moving on. From there, i want it to give me my average mouse speed say... every minute.

heres what ive got so far:



program new;
var x,y,nx,ny,startx,starty, endx, endy, starttime, endtime, dist, timedif, run, distperms: integer;
begin
Run:=0
repeat
Run:= Run + 1;
GetMousePos(x,y);
Wait(10)
GetMousePos(nx,ny);
if Distance(x,y,nx,ny) > 0 then
begin
StartTime:= GetTickCount;
StartX:= x;
StartY:= y;
Wait(1000)
GetMousePos(nx,ny);
EndTime:= GetTickCount;
dist:= distance(startx,starty,nx,ny);
timedif:= (endtime - starttime);
writeln(inttostr(Run)+': Distance = '+inttostr(dist)+'px, in '+inttostr(timedif)+'ms');
//distperms:= (dist/timedif)
//writeln(inttostr(Run)+':average = '+inttostr(distperms)+' pixel/ms.');
end else writeln(inttostr(Run)+' :No Change');
until (Run >= 100);
end.

ive got it waiting 1sec so i could have a constant to calculate pix/sec, but thats not working out.

distance only calculates from the original point, so its only good if im going in a straight line. how can i figure everywhere the mouse has been?

im also trying to figure out how i can have it recognize when my mouse stops moving? i was using "if distance(x,y, nx, ny) = 0 then blah blah" but that wasnt working for some reason.

idk its all a mess and ive been working on this stupid script for too long! i need help. maybe someone could point me in the direction of some knowledge that would help me?

thnx in advance.

Daniel
09-24-2010, 06:31 AM
Track every mouse movement? See: http://villavu.com/forum/showthread.php?t=49148 and learn from it ;)

massive630
09-25-2010, 06:46 AM
thanks alot! this will be mucho mucho helpful!