Markus
2007-05-30 12:42:08
When testing some of SRL's object finding functions, I always had the same problem:
It was moving the mouse to places where it already moved the mouse too, thus making it detectable and very, very slow.
As I was very annoyed I created a new function using FindColorSkipBoxArrayTolerance.
It will start using tolerance zero and only raises the tolerance if necessary. The set tolerance will be the max. tol.
Feel free to use this in any script, as long as you give credits.
It was moving the mouse to places where it already moved the mouse too, thus making it detectable and very, very slow.
As I was very annoyed I created a new function using FindColorSkipBoxArrayTolerance.
It will start using tolerance zero and only raises the tolerance if necessary. The set tolerance will be the max. tol.
{*******************************************************************************
function FindObjBoxSkip(var x, y : integer; color, tolerance : integer; text : string) : boolean;
By: Markus
Description: Will find an object using the set color and text. If the uptext isn't the right one,
it will create a 20x20 box around the point and starts looking again for the color.
Starts with tolerance zero and will raise if necessary until the set tolerance
*******************************************************************************}
function FindObjBoxSkip(var x, y : integer; color, tolerance : integer; text : string) : boolean;
var
cx, cy : integer;
tries : integer;
temptol : integer;
Tempbox : TBox;
Skipbox : TBoxArray;
begin
repeat
if FindColorSkipBoxArrayTolerance(cx, cy, color, msx1, msy1, msx2, msy2, temptol, skipbox) then
begin
MMouse(cx, cy, 1, 1);
if IsUpText(text) then
begin
result := true;
x := cx;
y := cy;
exit;
end else
begin
SetArrayLength(SkipBox, GetArrayLength(skipbox) + 1);
Tempbox.x1 := cx - 10;
Tempbox.y1 := cy - 10;
Tempbox.x2 := cx + 10;
Tempbox.y2 := cy + 10;
Skipbox[tries] := Tempbox;
tries := tries + 1;
end;
end else
begin
temptol := temptol + 1;
end;
until(temptol > tolerance);
end;
Feel free to use this in any script, as long as you give credits.