SRL Archive - SRL Snippets

isUpTextMMouse


omgnomorenames

2012-07-27 02:16:28

Edited on July/27/12 @ 11:38pm : Works great except on small objects added secondary isUpTextCheck since it sometimes doesn't see objects it ends at.

If any problems arise feel free to message me, and you're are more than free to take, use and edit this script (Just give me a little credit ;) ).

A little function of mine used to find upText while moving the mouse.

// isUpTextMMouse moves mouse until Text is found or mouse reaches position x,y
// returns True if Text is found and ends early
// returns False if Text is not found and mouse reaches position x,y
Function isUpTextMMouse (var x, y : Integer; Text : String): Boolean;
var x1,y1,z :Integer;
begin
Result := False;
GetMousePos (x1,y1);
x := x - x1;
y := y - y1;
z := 0;
writeln ('Start');
repeat
if (isUpText (Text)) then begin
writeln ('Found Text '+Text);
Result := True;
Exit;
end;
z:= z+1;
if (x < 0) then begin
MoveMouse (x1-z+Round(Random(2)*Cos(Random(100)*Pi*z/x)),y1+Round(y*z/(-x))-Round(Random(2)*Sin(Random(100)*Pi*z/x)))
end else if (x > 0) then begin
MoveMouse (x1+z+Round(Random(2)*Cos(Random(100)*Pi*z/x)),y1+Round(y*z/x)-Round(Random(2)*Sin(Random(100)*Pi*z/x)));
end else begin
while ((z = y) or (z = (-y))) do
begin
if (isUpText (Text)) then begin
Result := True;
Exit;
end;
if (y<0) then begin
MoveMouse (x1+Round(Random(2)*Cos(Random(100)*Pi*z/y)),y1-z+Round(Random(2)*Cos(Random(100)*Pi*z/y)));
end else if (y>0) then begin
MoveMouse (x1+Round(Random(2)*Cos(Random(100)*Pi*z/y)),y1+z+Round(Random(2)*Cos(Random(100)*Pi*z/y)));
end else begin
Exit;
end;
z := z +1;
end;
Exit;
end;
until ((z = x) or (z = (-x)))
wait (200);
if (isUpText (Text)) then begin
writeln ('Found Text '+Text);
Result := True;
end;
Writeln ('End');
end;

A fun little function that utilizes isUpTextMMouse by moving the mouse in a spiral till it finds Text or reaches limit (outside of screen).
// FindUpTextSpiral moves mouse in a spiral till text is found or reaches limit
// Returns True if Text is found
function FindUpTextSpiral (var Text : String):Boolean;
var
x : integer;
y : integer;
z : Integer;
begin
z := 0;
repeat
x := Round(z*Cos(0.5*z)+260);
y := Round(z*Sin(0.5*z)+224);
if (isUpTextMMouse(x,y,TexT)) then begin
writeln ('Found Text '+Text);
Result := True;
Exit;
end;
z := z+1;
until (z >= 250)
Result := False;
end;

Test Script Attempts to find bank
program new;
{.include SRL/SRL.simba}
var TEXT1 : String;
// 0,50 end 515,387


// isUpTextMMouse moves mouse until Text is found or mouse reaches position x,y
// returns True if Text is found and ends early
// returns False if Text is not found and mouse reaches position x,y
Function isUpTextMMouse (var x, y : Integer; Text : String): Boolean;
var x1,y1,z :Integer;
begin
Result := False;
GetMousePos (x1,y1);
x := x - x1;
y := y - y1;
z := 0;
repeat
if (isUpText (Text)) then begin
writeln ('Found Text '+Text);
Result := True;
Exit;
end;
z:= z+1;
if (x < 0) then begin
MoveMouse (x1-z+Round(Random(2)*Cos(Random(100)*Pi*z/x)),y1+Round(y*z/(-x))-Round(Random(2)*Sin(Random(100)*Pi*z/x)))
end else if (x > 0) then begin
MoveMouse (x1+z+Round(Random(2)*Cos(Random(100)*Pi*z/x)),y1+Round(y*z/x)-Round(Random(2)*Sin(Random(100)*Pi*z/x)));
end else begin
while ((z = y) or (z = (-y))) do
begin
if (isUpText (Text)) then begin
Result := True;
Exit;
end;
if (y<0) then begin
MoveMouse (x1+Round(Random(2)*Cos(Random(100)*Pi*z/y)),y1-z+Round(Random(2)*Cos(Random(100)*Pi*z/y)));
end else if (y>0) then begin
MoveMouse (x1+Round(Random(2)*Cos(Random(100)*Pi*z/y)),y1+z+Round(Random(2)*Cos(Random(100)*Pi*z/y)));
end else begin
Exit;
end;
z := z +1;
end;
Exit;
end;
until ((z = x) or (z = (-x)))
end;

function FindUpTextSpiral (var Text : String):Boolean;
var
x : integer;
y : integer;
z : Integer;
begin
z := 0;
repeat
x := Round(z*Cos(0.5*z)+260);
y := Round(z*Sin(0.5*z)+224);
if (isUpTextMMouse(x,y,TexT)) then begin
writeln ('Found Text '+Text);
Result := True;
Exit;
end;
z := z+1;
until (z >= 250)
Result := False;
end;

begin
SetupSRL;
TEXT1 := 'ank';
wait (1000);
if (FindUpTextSpiral (TEXT1)) then
begin
writeln ('Success');
end;
end.

Justin

2012-07-27 05:04:58

Looks nice man, could come in handy.

omgnomorenames

2012-07-27 11:44:54

Thank You

Joe

2012-07-27 11:53:54

This should be in the include suggestions, no? But it actually sounds very good. but wouldn't

begin
while MMouse do
isuptext('umad');
end;

Not sure if it's right but its what came to mind. Theres a lot of good that could come from moving the mouse to check for correct targets.
Bravo and rep+

~Joe

omgnomorenames

2012-07-27 13:50:37

MMouse would work but it is incredible slow, now mine is a little too fast, testing wait times which are more reasonable.

jared0565

2012-07-28 11:32:37

This one is good, but is this safe? Isn't this detected as it will use the same pattern everytime you search for a particular uptext?

omgnomorenames

2012-07-28 13:20:30

Now If you know a little math, you can tell that this thing would be all over the ****ing place if the amplitude was any bigger, thus it never will have the same movement, but it will only look like basic mouse twitches to the computer.
 MoveMouse (x1+Round(Random(2)*Cos(Random(100)*Pi*z/y)),y1-z+Round(Random(2)*Cos(Random(100)*Pi*z/y)));
The secondary search function is only to show the uses of the upTextMMouse function, it's practicality is limited, and should only really be used once or twice if at all.

Fakepot

2012-12-20 09:55:47

Dude can you make one of those Horsebots

it should be simple as the only thing the bots gona do is click on the horse!

please?

Austin

2012-12-20 09:59:14

From: Fakepot
Dude can you make one of those Horsebots

it should be simple as the only thing the bots gona do is click on the horse!

please?

It is quite simple, go over to the tutorial section to learn how to make it.

PS: Why post about that on this thread?