From: Sir R. Magician
@Zytex: Coh3n is right. Your function potentially could lag us to hell. I'd suggesting just choosing a side to have the mouse go out from (randomly) and make sure it does.
~RM
I noticed the CPU use went up to 50% on both processses, so we can do it like this instead:
procedure LeaveMainScreen(HowLong : Integer);
var
ClientBox, B : TBox;
w, h, X, c : Integer;
P : TPoint;
begin
GetClientDimensions(w, h);
ClientBox := IntToBox(0, 0, w, h);
B := IntToBox(-30, -30, w+30, h+30);
while PointInBox(P, ClientBox) do
begin
P := Point(RandomRange(B.X1, B.X2), RandomRange(B.Y1, B.Y2));
Wait(1); // To stop lag
Inc(c);
if c > 50 then // To stop it from looping
MMouse(-30, -30, 0, 0);
end;
MMouse(P.X, P.Y, 0, 0);
Wait(HowLong);
end;
I don't like it when it moves the mouse in the same direction :/