SRL Archive - Test corner

Mouse function


jimmy_mac

2010-01-07 08:28:45

Hey let me know what you think of this. its just adding some randomness to the Mouse function. Makes it so that the mouse moves past the spot you define then back to it. If it's useful add it, else hit us up with some CC.

E: If you wanna test, run the script below. change the values in Mouse2(); down the bottom.
E: Ok so how does this look? also what do you think about it in general? worth using or not?
program Mouse;
{.include srl/srl.scar}

procedure Mouse2(mousex, mousey, ranx, rany: Integer; left: Boolean);
var
a, b, c, x1, x2, y1, y2: Integer;
begin
GetMousePos(x1, y1);
x2 := mousex + ((mousex - x1) div RandomRange(10, 20));
y2 := mousey + ((mousey - y1) div RandomRange(10, 20));
ranx := random(ranx);
rany := random(rany);
MMouse(x2+ranx, y2+rany, 0, 0);
if (not InRange(x2, mousex, mousex+ranx)) and (not InRange(y2, mousey, mousey+rany)) then
begin
wait(20+random(15));
MMouse(mousex+ranx, mousey+rany, 0, 0);
end;
wait(60+random(30));
GetMousePos(b, c);
HoldMouse(b, c, left);
repeat
Wait(20 + Random(30));
a := a + 1;
until (a > 4);
GetMousePos(b, c);
ReleaseMouse(b, c, left);
Wait(100 + Random(100));
end;

begin
SetupSRL;
Mouse2(111, 709, 5, 5, True);
end.

mixster

2010-01-07 10:03:14

Before I look at it, you should use SCAR tags (
without the spaces) when posting Scar code so it's nicely formatted.

Edit:
It seems to me you have very much overcomplicated the beginning for no reason.

For working out the x and y including a little extra (due to missing), you could just do something like:

x2 := mousex + ((mousex - x1) div RandomRange(10, 20));

Then for y just replace x with y.

This would work because is mousex > x1 then mousex - x1 will be positive and so when divided by a number (ie 10) it will be positive, thus be eqal to mousex + posNumber. If mousex < x1, then mousex - x1 will be negative, thus a negative number results when divided and so becomes mousex + negNumber.

Next, I don't think you would need to modify the mousespeed or have the small wait times as usually people would naturally react quite quickly to it. I would then say you don't need to add the 4, 4 as ranx and rany values for MMouse if you are already applying ranx and rany values to the destination - this could mean that it's an extra 4 pixels away from the place where they actually wanted to click.

I would also say it makes more sense to apply this to MMouse rather than Mouse - better yet you could easily manage it by using recursion and would suggest using a little check to see if you missed it but still are inside the box around which the user wanted to be in as it would be silly to correct the position if it still would be correct where it is.

jimmy_mac

2010-01-07 10:15:36

E: Thanks for the tips mixter :) ill try em out.

mixster

2010-01-07 10:25:55

It may look better to you, but to anyone trying to read it the Scar formatting helps a lot, also edited above post with comments relating to the mod.

jimmy_mac

2010-01-07 10:49:29

yeh dont worry, the scar ones look better i duno what i was thinking :S haha.. what do you think? is it any good? or worth adding?

E: first post is changed with updated script.

mixster

2010-01-07 11:07:01

I would say probably not. There has been related discussion in another thread and to me, and a few others, M/Mouse are fine as most believe Jagex only records clicks and that if it was detectable, then everybody would be banned.

jimmy_mac

2010-01-07 11:21:44

fair call, I just read about someone suggesting somewhere on these forums I thought.. haha oh well i was just messin bout anyway.