Death12652
2011-04-20 21:57:41
Is there a way to check if the mouse is moving?
2011-04-20 21:57:41
2011-04-20 22:02:03
function IsMouseMoving: Boolean;
var
x, y, x2, y2: Integer;
begin
GetMousePos(x, y); //Get mouse position
Wait(10); //Wait 10 ms
GetMousePos(x2, y2); //Get mouse position to compare to
Result := (x2 <> x) or (y2 <> y); //if x or y coord is different mouse is moving
end;
Not the greatest but it would work.
2011-04-21 00:48:29
2011-04-21 01:18:09
From: KingKong
^It won't work with smart, since mmouse/mouse has to be finished and then your code must be run, by which time the mouse would've stopped moving, but it will if you select the rs client and use the actual mouse.
2011-04-21 04:33:46
From: Smartzkid
You shouldn't have any reason to check if the mouse is moving from within the script that's moving the mouse?
2011-04-21 04:46:21
Var
FT : Boolean; // global
function IsMouseMoving: Boolean;
var
x, y, x2, y2: Integer;
begin
If Not FT Then
Begin
GetMousePos(x, y); //Get mouse position
FT := True;
Exit;
End;
GetMousePos(x2, y2); //Get mouse position to compare to
Result := (x2 <> x) or (y2 <> y); //if x or y coord is different mouse is moving
FT := False;
end;
// no need for the wait anymore.
Begin
IsMouseMoving;
MMouse(34, 45, 5, 5);
WriteLn(+BoolToStr(IsMouseMoving));
End.
Havent compiled anything here so idno if it'll run without errors.
2011-04-21 04:52:34
2011-04-21 05:57:43
From: KingKong
^Just a little flaw in your code:
You can't edit global variables like that, and i don't know if pascalscript allows it(if it does i don't know how to implement it)
Var
prevPoint:TPoint = Point(0,0);
function IsMouseMoving: Boolean;
var
x, y: Integer;
begin
If Not(prevPoint = Point(0,0)) Then
Begin
GetMousePos(x, y); //Get mouse position
prevPoint := Point(x,y);
Exit;
End;
GetMousePos(x, y); //Get mouse position to compare to
Result := not(prevPoint = Point(x,y));
prevPoint := Point(0,0);
end;
2011-04-21 06:20:51
2011-04-21 08:57:34