Log in

View Full Version : Recommend Mouse Procedure?



endr1x
02-14-2007, 09:03 PM
JUst a small question, Which Mouse Procedure do you think is the best to use taking into account detectability?

~Endr1x~ (h)

Boreas
02-14-2007, 09:09 PM
Mouse for moving and clicking
MMouse for just moving

Look in SRL/core/MouseFlag.scar

the flea
02-15-2007, 08:26 PM
i say a mixture ;) this might make it longer to make when making the script but its a lot more undetectable since it means your more like a human doing things differently instead of the same all the time.

Boreas
02-16-2007, 12:01 AM
Mouse and MMouse already do it differently. For a test, do

MMouse-startpoint
HoldMouse
MMouse-end point
ReleaseMouse

repeat that a few times in paint with the pencil. It will take a different path each time.

Smartzkid
02-16-2007, 12:56 AM
Well, sorry to all you SRL peeps around here, but I'd have to side with deadmouse (400 line mouse procedure!)

It can be found here-http://www.moparisthebest.com/smf/index.php/topic,7455.0.html (http://www.moparisthebest.com/smf/index.php/topic,7455.0.html)

deadmouse(500,500,15,10,4); made this test pic:
http://img233.imageshack.us/img233/9964/mousecomparepa5.jpg

Custom deadmouse.scar with custom variables to work with SRL is at the bottom.


program MouseTest;
var
i:integer;
{.include SRL\SRL.scar}
{.include deadmouse.scar}
begin
SetupSRL;
ActivateClient;
wait(500);

for i:= 1 to 10 do
begin
MMouse(5,5,0,0);
HoldMouse(5,5,true);
MMouse(250,250,0,0);
ReleaseMouse(250,250,true);
end;

wait(1000);
for i:= 1 to 10 do
begin
movemouse(275,275);
HoldMouse(275,275,true);
deadmouse(500,500,15,10,4);
ReleaseMouse(500,500,true);
end;
end.


(* Realistic mouse script by *DEAD*
Ok, this is my first mouse script worthy of releasing, and it looking really good.
Its a different type of mouse script design from all my others and most others
ive seen. It works by "homing" in on a target, which means you can "bump" the mouse
randandomly change its direction, and it would correct itself, much like a real person would.

There are lots of required varables, so ill go through them.

tomouse(targx,targy,maxspeed,minspeed,square,accur acy,turnspeed,acceleration,deceleration:integer; finishingtouch:boolean);
targx and targy are the x,y coords of the point the mouse is to move to.
maxspeed is the speed at which the mouse accelerates to.
minspeed is the minimum speed of the mouse, with out it the mouse would stop (i intend to find a work around which will fix this).
Think of square as the randomness of each small mouse movement. Each time the script is given a coordanate to move to, the mouse moves to a coordanate close to that point which is inside a square.
accuracy is how close the cursor has to be to the target before it stops
turnspeed is how fast the mouse can change direction. This is actually a percentage (0 - 100) of the difference between the target angle and the current angle (i recomend 20 - 25) (known glitch, sometimes it will just keep circling around the target, im working on it)
acceleration is the rate at which the mouse accelerates(%)
deceleration is the rate at which the mouse decelerates(%)

finishingtouch will move the mouse to the target after the main move mouse script stops. With out this, the mouse could stop within "accuracy" pixels from the target
there is one more varable, curangle. This is a global, but when i release the actual script it will be fixed. Curangle is the angle at which the mouse is traveling at any given time. If you change its start value, the mouse will start moving in a different direction. Remember, since on a computer screen the y axis is at the top of the screen and counts up as it goes down, the circle will be inverted. so 90 is downward, 270 is upward, 0 is right, and 180 is left.


The best thing about this script is that its easy to add on to.
Ive included a "bump" procedure which randomly change the mouses direction,
and the the mouse will correct itself all by itself. cool eh. This means
you can do anything from making a quick jolt, to emulating the mouse falling
off the desk.

(UPDATE)
now that the script is complete, i have made it alot simpler.
the procedure is now
deadmouse(targx,targy,speed,turnspeed,acceleration :integer; finishingtouch:boolean);
finishing touch isnt really neccesary any more, however i guess it would help.

Enjoy
*)

var
finishingtouch,overshoot:boolean;

function loge(i:extended) : extended;
var
count,exp:integer;
xval:extended;
begin
exp:= 1;
xval:= (i - 1) / (i + 1);
for count:= 1 to 5 do
begin
result:= result + pow(xval,exp)/exp;
exp:= exp + 2;
end;
result:= result * 2;
end;

function logb(base,i:extended) : extended;
begin
result:= loge(i)/loge(base);
end;

function abscustom(i : extended) : extended;
begin
i:= sqrt(i*i);
result := i;
end;

function fact(i : integer) : integer;
var
holdi,res : integer;
begin
holdi := i;
res := 1;
for i := 1 to holdi do
begin
res := i * res
end;
result := res;
end;

function arctancustom(e : extended) : extended;
var
count : integer;
res : extended;
inv : boolean;
begin
if(abscustom(e) > 1)then
begin
e := pow(e,-1);
inv := true;
end else
begin
inv := false;
end;
for count := 0 to 6 do
begin
res := res + ( ( pow(2,2 * count) * pow(fact(count),2) ) / fact(2 * count + 1) ) * ( ( pow(e,2*count+1) ) / ( pow(1 + pow(e,2),count + 1) ) );
end;
if(inv)then
begin
res := 1.5707963267 - res;
end;
result := res;
end;

procedure findintercept(var x,y:integer; targx,targy,radius:integer; i,j:extended);
begin
x:= round(x + i * radius);
y:= round(y + j * radius);
end;

procedure adjangle(x,y,targx,targy,rate:integer; var i,j:extended; var curangle:integer);
var
targangle,degreescustom,angledifft,anglediffc:inte ger;
radianscustom:extended;
begin
if(targx - x = 0) or (targy - y = 0)then
begin
if(targx - x = 0)then
begin
if(targy - y > 0)then
begin
targangle:= 270;
end else
begin
targangle:= 90;
end;
end;
if(targy - y = 0)then
begin
if(targx - x > 0)then
begin
targangle:= 180;
end else
begin
targangle:= 0;
end;
end;
end else
begin
degreescustom:= round(arctancustom(abscustom((x - targx)/(y - targy))) * 180 / pi);
if(targx - x > 0)then
begin
if(targy - y > 0)then
begin
targangle:= 90 - degreescustom;
end else
begin
targangle:= 270 + degreescustom;
end;
end else
begin
if(targy - y > 0)then
begin
targangle:= 90 + degreescustom;
end else
begin
targangle:= 270 - degreescustom;
end;
end;
end;
anglediffc:= curangle - targangle;
angledifft:= targangle - curangle;
if(anglediffc < 0)then
begin
anglediffc:= anglediffc + 360;
end;
if(angledifft < 0)then
begin
angledifft:= angledifft + 360;
end;
if(curangle <> targangle)then
begin
if(angledifft > anglediffc)then
begin
curangle:= curangle - round(rate / 100 * anglediffc);
end else
begin
curangle:= curangle + round(rate / 100 * angledifft);
end;
end;
if(curangle < 0)then
begin
curangle:= curangle + 360;
end;
if(curangle > 360)then
begin
curangle:= curangle - 360;
end;
radianscustom:= curangle * pi / 180;
i:= cos(radianscustom);
j:= sin(radianscustom);
end;

procedure bump(var curangle:integer);
begin
if(random(10) < 1)then
begin
curangle:= round(curangle - 0.5 * 40 + random(40));
end;
end;

procedure accelerate(x,y,targx,targy,speed,acceleration:inte ger; var curspeed:extended; var decelerate:boolean);
var
dist,dedist,deceleration,time:extended;
begin
deceleration:= -acceleration / 100 + 1;
if(curspeed <> 0)then
begin
dist:= sqrt(pow(targx - x, 2) + pow(targy - y, 2));
time:= logb(deceleration,5/curspeed);
dedist:= curspeed * (1 - pow(deceleration,time))/(1 - deceleration);
end else
begin
dedist:= dist - 1;
end;
if(dist < dedist)then
begin
decelerate:= true;
end;
if(decelerate)then
begin
if(curspeed > 5)then
begin
curspeed:= curspeed * deceleration;
end;
end else
begin
curspeed:= curspeed + acceleration / 100 * (speed - curspeed);
end;
end;

procedure changeturnspeed(x,y,targx,targy,turnspeed,totaldis t:integer; var curturnspeed :integer);
var
dist:extended;
hold:integer;
exp:integer;
begin
if(totaldist > 100)then
begin
exp:= 2;
end else
begin
exp:= totaldist/100;
end;
dist:= sqrt(pow(targx - x, 2) + pow(targy - y, 2));
hold:= round(pow(100 - turnspeed,pow((totaldist - dist)/totaldist,exp)) + turnspeed);
if(hold > curturnspeed)then
begin
curturnspeed:= hold;
end;
end;

procedure randomcurangle(x,y,targx,targy:integer; var curangle:integer);
var
targangle,degreescustom:integer;
begin
if(targx - x = 0) or (targy - y = 0)then
begin
if(targx - x = 0)then
begin
if(targy - y > 0)then
begin
targangle:= 270;
end else
begin
targangle:= 90;
end;
end;
if(targy - y = 0)then
begin
if(targx - x > 0)then
begin
targangle:= 180;
end else
begin
targangle:= 0;
end;
end;
end else
begin
degreescustom:= round(arctancustom(abscustom((x - targx)/(y - targy))) * 180 / pi);
if(targx - x > 0)then
begin
if(targy - y > 0)then
begin
targangle:= 90 - degreescustom;
end else
begin
targangle:= 270 + degreescustom;
end;
end else
begin
if(targy - y > 0)then
begin
targangle:= 90 + degreescustom;
end else
begin
targangle:= 270 - degreescustom;
end;
end;
end;
curangle:= targangle - 45 + random(90);
if(curangle > 0)then
begin
curangle:= curangle + 360;
end;
end;

procedure gravity(var x,y:integer; gravpointx,gravpointy,grav,pull:integer);
var
gravx,gravy:integer;
slope:extended;
begin
if(x - gravpointx = 0)or(y - gravpointy = 0)then
begin
if(x - gravpointx = 0)then
begin
gravy:= grav;
end else
begin
gravx:= grav;
end;
end else
begin
repeat
if(not(y-gravy>0))then
gravy:=gravy+1;
until(y-gravy>0)
slope:= (x - gravx)/(y - gravy);
gravx:= round(grav/(1 + slope));
gravy:= round((grav/(1 + slope)) * slope);
end;
if(gravpointx > x)then
begin
x:= x - gravx;
end else
begin
x:= x + gravx;
end;
if(gravpointy > y)then
begin
y:= y - gravy;
end else
begin
y:= y + gravy;
end;
end;

procedure deadtomouse(targx,targy,maxspeed,turnspeed,acceler ation:integer);
var
curspeed:extended;
square,totaldistance,curturnspeed,grav,gravpointx, gravpointy,pull:integer;
i,j:extended;
x,y:integer;
decelerate:boolean;
curangle:integer;
begin
getmousepos(x,y);
curspeed:= 0;
totaldistance:= round(sqrt(pow(targx - x, 2) + pow(targy - y, 2)));
randomcurangle(x,y,targx,targy,curangle);
pull:= random(2);
gravpointx:= random(round(abscustom(targx-x)));
gravpointy:= random(round(abscustom(targy-y)));
if(targx > x)then
begin
gravpointx:= targx - gravpointx;
end else
begin
gravpointx:= targx + gravpointx;
end;
if(targy > y)then
begin
gravpointy:= targy - gravpointy;
end else
begin
gravpointy:= targy + gravpointy;
end;
repeat
accelerate(x,y,targx,targy,maxspeed,acceleration,c urspeed,decelerate);
changeturnspeed(x,y,targx,targy,turnspeed,totaldis tance,curturnspeed);
adjangle(x,y,targx,targy,curturnspeed,i,j,curangle );
findintercept(x,y,targx,targy,round(curspeed),i,j) ;
if(decelerate <> true)then
begin
gravity(x,y,gravpointx,gravpointy,grav,pull);
end;
grav:= round(curspeed * 0.25);
bump(curangle);
square:= round(curspeed / 4);
x:= round(x + random(square) - 0.5 * square);
y:= round(y + random(square) - 0.5 * square);
movemouse(x,y);
wait(10 + random(10));
until(y < targy + 10)and(y > targy - 10)and(x < targx + 10)and(x > targx - 10);
if(finishingtouch)then
begin
movemouse(targx,targy)
end;
end;

procedure deadmouse(targx,targy,maxspeed,turnspeed,accelerat ion:integer);
var
metatargx,metatargy,overshootdist,totaldist,x,y:in teger;
begin
if(overshoot)then
begin
if(random(4) < 3)then
begin
getmousepos(x,y);
totaldist:= round(sqrt(pow(targx - x, 2) + pow(targy - y, 2)));
writeln(inttostr(totaldist));
overshootdist:= round(totaldist * 0.1 + random(round(totaldist*0.1)));
if(totaldist > round(0.5 * maxspeed)) then
begin
overshootdist:= overshootdist + random(maxspeed * 2);
end;
if(random(2) = 1)then
begin
metatargx:= targx + overshootdist;
end else
begin
metatargx:= targx - overshootdist;
end;
overshootdist:= random(2 * maxspeed);
overshootdist:= overshootdist + maxspeed;
if(random(2) = 1)then
begin
metatargy:= targy + overshootdist;
end else
begin
metatargy:= targy - overshootdist
end;
deadtomouse(metatargx,metatargy,maxspeed,turnspeed ,acceleration);
wait(100 + random(200));
end;
end;
deadtomouse(targx,targy,maxspeed,turnspeed,acceler ation);
end;

Creds to *DEAD* for this awesome mouse procedure

Hey321
02-16-2007, 02:39 AM
program New;
{.include SRL/SRL.scar}

procedure test;
begin
MMouse(128, 170, 0, 0);
GetMousePos(x, y);
HoldMouse(x, y, true);
MMouse(1079, 670, 0, 0);
GetMousePos(x, y);
ReleaseMouse(x, y, True);
end;


begin
SetupSRL;
ActivateClient;
repeat
test;
until(false)
end.

Run that in paint with the canvas as big as you can get it. Watch it a few times :P.

Infantry001
02-16-2007, 03:51 AM
Atcually, i prefer deadmouse better. But since all SRL procs are already callibrated for Benmouse's spline, i use his :P

Smartzkid
02-16-2007, 04:15 AM
also-some of deadmouse's variables conflict with srl's, so i had to change some stuff in it; thats why I posted my own version. I also fixed a div by 0 error that i got pretty often.

YoHoJo
02-16-2007, 05:29 AM
I go with MMouse.
It takes a more direct rout to the point and its smoother
Deadmouse seems way too random and shakey like an old man having sex is playing runescape.

But thats just my opinion

Deadmouse stuff looks cool though.

Smartzkid
02-16-2007, 05:41 AM
:D haha old man

I think you could make Deadmouse less shakey...just set the turning acceleration lower

Hey321
02-16-2007, 03:18 PM
I go with MMouse.
It takes a more direct rout to the point and its smoother
Deadmouse seems way too random and shakey like an old man having sex is playing runescape.

But thats just my opinion

Deadmouse stuff looks cool though.

Owned rofl!

Bobarkinator
02-16-2007, 04:21 PM
In the pic I think that MMouse looks more like what he did himself than deadmouse does

Smartzkid
02-16-2007, 07:59 PM
hmmm....I have to agree...I guess I'll have to try messin with the settings some...

EDIT: Tweaked settings, and it came out a whole lot better! Uploaded new image, and added the fixed deadmouse code to the test script

Hobbit
02-17-2007, 01:30 AM
EDIT: Tweaked settings, and it came out a whole lot better! Uploaded new image, and added the fixed deadmouse code to the test script

mmouse still looks closer to urs then deadmouse...dead mouse looks like its trying to recreate a guy high on pot during an earthquake trying to draw lines