Simba Code:
function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
Tol, Step, xs, ys, xe, ye: Integer): Boolean;
var
MidX, MidY, i, j, k, x, y, width, height, HalfWidth, HalfHeight: Integer;
ColorFound: Boolean;
SearchBoxes: Array of Array of TBox;
p: TPointArray;
begin
Result := False;
//check for all the colors
for i := 0 to (GetArrayLength(Color)-1) do
if (FindColorSpiralTolerance(cx, cy, Color[i], xs, ys, xe, ye, Tol)) then
begin
ColorFound := True;
Break;
end;
if not(ColorFound) then
Exit; //None of the colors could be found on screen
//Start coordinates
MidX := Round((xe - xs) / 2);
MidY := Round((ye - ys) / 2);
//width and height in boxes
Width := Ceil(abs(xe - xs) / 2 / Step - 0.5) * 2 + 1;
Height := Ceil(abs(ye - ys) / 2 / Step - 0.5) * 2 + 1;
SetLength(SearchBoxes, Width);
HalfWidth := Floor(Width / 2);
HalfHeight := Floor(Height / 2)
for x := -1 * HalfWidth to HalfWidth do
begin
SetLength(SearchBoxes[x + HalfWidth], Height);
for y := -1 * HalfHeight to HalfHeight do
SearchBoxes[x + HalfWidth][y + HalfHeight] := IntToBox(
Max(xs, xs + Round(MidX + ((x - 0.5) * Step))),
Max(ys, ys + Round(MidY + ((y - 0.5) * Step))),
Min(xe, xs + Round(MidX + ((x + 0.5) * Step))),
Min(ye, ys + Round(MidY + ((y + 0.5) * Step))));
end;
p := TPAFromBox(IntToBox(0, 0, Width-1, Height-1));
SortTPAFrom(p, Point(floor(Width / 2), floor(Height / 2)));
for k := 0 to High(Color) do
for j := 0 to High(p) do
begin
if (FindColorTolerance(cx, cy, Color[k], SearchBoxes[p[j].x][p[j].y].x1,
SearchBoxes[p[j].x][p[j].y].y1, SearchBoxes[p[j].x][p[j].y].x2,
SearchBoxes[p[j].x][p[j].y].y2, Tol)) then
begin
MMouse(cx, cy, 3, 3);
If (WaitUptextMulti(Text, 300)) then
begin
GetMousePos(cx, cy);
Result := True;
Exit;
end;
end;
end;
end;