BryceTheCoder Posted December 1, 2015 Share Posted December 1, 2015 Hey guys! This is mainly for Wanted or Freddy: I am trying to simulate human mouse movements like MMouse function does. procedure MMouse(X, Y, RX, RY: Integer); var P: TPoint; B1: TBox; begin B1 := Box(X - RX, Y - RY, X + RX, Y + RY); P := RRectanglePoint(B1.X1, B1.Y1, B1.X2, B1.Y2); if (MouseSpeed <> 0) then MoveMouseEx(P.X, P.Y, RR(MouseSpeed - 3, MouseSpeed + 3)) else MoveMouse(P.X, P.Y); GetMousePosP(P); if (IAbs(P.X - X) > RX) then SetMousePos(X, P.Y); GetMousePosP(P); if (IAbs(P.Y - Y) > RY) then SetMousePos(P.X, Y); end; I can recode all that, however, this line: MoveMouseEx(P.X, P.Y, RR(MouseSpeed - 3, MouseSpeed + 3)) Where is the code for the function MoveMouse ? Quote Link to comment Share on other sites More sharing options...
Wanted Posted December 1, 2015 Share Posted December 1, 2015 Inside SCAR. If you're looking for source to something similar I could probably post the old MMouse from SRL 4. Quote Link to comment Share on other sites More sharing options...
BryceTheCoder Posted December 1, 2015 Author Share Posted December 1, 2015 Inside SCAR. If you're looking for source to something similar I could probably post the old MMouse from SRL 4. Okay yah, that will probably be very helpful if you could! Quote Link to comment Share on other sites More sharing options...
Wanted Posted December 1, 2015 Share Posted December 1, 2015 {******************************************************************************* procedure WindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended); By: Benland100 Description: *******************************************************************************} procedure WindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended); var veloX, veloY, windX, windY, veloMag, dist, randomDist, lastDist, step: extended; lastX, lastY: integer; sqrt2, sqrt3, sqrt5: extended; begin sqrt2:= sqrt(2); sqrt3:= sqrt(3); sqrt5:= sqrt(5); while hypot(xs - xe, ys - ye) > 1 do begin dist:= hypot(xs - xe, ys - ye); wind:= minE(wind, dist); if dist >= targetArea then begin windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5; windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5; end else begin windX:= windX / sqrt2; windY:= windY / sqrt2; if (maxStep < 3) then begin maxStep:= random(3) + 3.0; end else begin maxStep:= maxStep / sqrt5; end; end; veloX:= veloX + windX; veloY:= veloY + windY; veloX:= veloX + gravity * (xe - xs) / dist; veloY:= veloY + gravity * (ye - ys) / dist; if hypot(veloX, veloY) > maxStep then begin randomDist:= maxStep / 2.0 + random(round(maxStep) div 2); veloMag:= sqrt(veloX * veloX + veloY * veloY); veloX:= (veloX / veloMag) * randomDist; veloY:= (veloY / veloMag) * randomDist; end; lastX:= Round(xs); lastY:= Round(ys); xs:= xs + veloX; ys:= ys + veloY; if (lastX <> Round(xs)) or (lastY <> Round(ys)) then MoveMouse(Round(xs), Round(ys)); step:= hypot(xs - lastX, ys - lastY); wait(round((maxWait - minWait) * (step / maxStep) + minWait)); lastdist:= dist; end; if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then MoveMouse(Round(xe), Round(ye)); end; {******************************************************************************* procedure MMouse(x, y, rx, ry: integer); By: Benland100 Laptop Movement by Hobbit with help from nielsie95! Description: Moves the mouse. *******************************************************************************} procedure MMouse(x, y, rx, ry: integer); var cx, cy: integer; randSpeed: Extended; {$IFDEF UseLaptopMouse} seg, e, f, g, nx, ny, hypo: Integer; a, b, c: Extended; Miss: Boolean; {$ENDIF} begin GetMousePos(cx, cy); {$IFDEF UseLaptopMouse} miss := (Random(LMouse_MissChance) = 0); e:= 0; a:= x - cx; b:= y - cy; c:= Pow(a,2) + Pow(b,2) hypo:= Round(Sqrt(c)); case hypo of 0: Exit; 1..225: seg:=1; 226..600: seg:= Random(2) + 1; 601..1800: seg:= random(3) + 2; else seg := 5; end; f := Round( a / seg); g := Round( b / seg); repeat Wait(30 + random(50)); {Begin: Modified from MMouse by Benland100} randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0; if randSpeed = 0.0 then randSpeed := 0.1; getMousePos(cx,cy); nx:= (cx + (f * e)) + random(rx); ny:= (cy + (g * e)) + random(ry); {End: Modified from MMouse by Benland100} if Miss then begin nx:= nx + RandomRange(rx, rx * 2); ny:= ny + RandomRange(ry, ry * 2); end; WindMouse(cx,cy,nx,ny,11.0,8.0,10.0/randSpeed,12.0/randSpeed,10.0*randSpeed,10.0*randSpeed); e:= e + 1; until(e = seg); GetMousePos(cx, cy); if not PointInBox(Point(cx, cy), IntToBox(x, y, x + rx, y + ry)) then begin Wait(30 + random(30)); WindMouse(cx,cy,(x + random(rx)),(y + random(ry)),11.0,6.0,10.0/randSpeed,15.0/randSpeed,10.0*randSpeed,10.0*randSpeed); end; {$ELSE} randSpeed:= (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0; if randSpeed = 0.0 then randSpeed := 0.1; X := x + random(rx); Y := y + random(ry); WindMouse(cx,cy,x,y,9.0,3.0,10.0/randSpeed,15.0/randSpeed,10.0*randSpeed,10.0*randSpeed); {$ENDIF} end; 1 Quote Link to comment Share on other sites More sharing options...
BryceTheCoder Posted December 1, 2015 Author Share Posted December 1, 2015 .... AMAZING! Thank you very much Wanted! I have the code now saved, if you need to remove it. Very helpful though, thank you very much! Quote Link to comment Share on other sites More sharing options...