SRL Archive - OSR Help

Mouse vs Efficiency


PhaseCode

2012-03-03 01:55:35

Alright Guys, so recently I was working on several mouse methods because I need to send a mouse click as fast as possible, move to another color and click it as fast as possible.

So The first method I'm going to be talking about is MMouse and Mouse ( Now these are two different methods but the difference between the two is about 3 milliseconds. So If we look at MMouse's code.

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;

Now if you analyze that code, you see that it first has to calculate a random range, and passes that into WindMouse which does some more calculating on pushing the mouse on a spline.
So here is my result ( in milliseconds ).

421
375
452
359
405
374
406
374
422
390
405
390
390
375
421
374
405
390
359
405
390
406
390
405
390
374
437
406
375
452
390
390
As you can see at about 400 milliseconds a push at lets say 200 pushes can really slow down a program.
Now lets look at a direct call to Mouse.
A direct call to the MoveMouse method rather then the MMouse is a api call to Smart/The interpreter.

250
281
249
250
249
250
234
250
234
250
202
266
234
234
234
280
250
265
218
266
202
203
218
265
281
250
218
218
234
202
250
218
265
266
265
265
234
218
234
281
250
249
234
281
203
250
234
249
219
249
So you can do
  
MoveMouse(X,Y);
ClickMouse2(1);
rather then

MMouse(X,Y,RanX,RanY);

My Two Cents.

Brandon

2012-03-03 02:04:24

-_____- A complain thread about a human mouse?

If u want to get banned I suggest u start using MoveMouse(X, Y);

Daniel

2012-03-03 02:37:04

Mouse uses MMouse which uses WindMouse. You should never call MMouse which is followed by Mouse.

Mouse = MMouse + Click

PhaseCode

2012-03-03 02:41:34

From: ggzz
-_____- A complain thread about a human mouse?

If u want to get banned I suggest u start using MoveMouse(X, Y);


If I don't wish to get banned, I could easily do

 MoveMouse(NewX + Random(10),NewY + Random(10));    

Which add's ~ 3-4 milliseconds.

Brandon

2012-03-03 03:10:09

From: PhaseCode
If I don't wish to get banned, I could easily do

Simba Code:
[LEFT]MoveMouse(NewX + Random(10),NewY + Random(10));
[/LEFT]


Which add's ~ 3-4 milliseconds.


3-4 milliseconds is nothing.. Random(10) added 6 seconds total to it for me.. for "200" runs.

YoHoJo

2013-04-06 13:37:09

I don't understand what you are trying to get at here.
When writing a script for RS you should use human-like mouse movment like Mouse/MMouse.
Using MoveMouse/CickMouse on RS will get you banned in a snap, however if you are writing a Simba scripts for something else which doesn't check for macros, then go ahead and use MoveMouse/ClickMouse.

I'm moving this out of tutorial section since it's not really of a tutorial and may confuse some new people.

PFFFT 1 Year Grave Dig.
Not my fault, someone reported this post.