Try my dual-color searching function:
Simba Code:
Function FindObjEx_F(ColorA, ColorB, Tol, Bounds, sX, sY: Integer; UpText: TStringArray; Var X, Y: Integer; Debug: Boolean): Boolean;
var
B: TBox;
TPA: TPointArray;
L,i,CTS: Integer;
ATPA,ATPA2: T2DPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(sX, sY, TPA, ColorA, MSX1, MSY1, MSX2, MSY2, Tol)
ColorToleranceSpeed(CTS);
if Length(TPA) < 1 then
Exit;
ATPA := TPAtoATPAEx(TPA, Bounds, Bounds);
L := High(ATPA);
SetArrayLength(ATPA2, L+1);
for i := 0 to L do
begin
B := GetTPABounds(ATPA[i]);
with B do
begin
FindColorsSpiralTolerance(sX, sY, ATPA2[i], ColorB, B.X1, B.Y1, B.X2, B.Y2, Tol)
if Length(ATPA2[i]) > 0 then
begin
MiddleTPAEx(ATPA2[i], X, Y);
HumanMMouse(X, Y, 5, 5);
if WaitUpTextMulti(UpText, 800) then
begin
Result := True;
if DeBug then
SMART_DrawBox(IntToBox(X-Bounds, Y-Bounds, X+Bounds, Y+Bounds));
GetMousePos(X, Y);
Exit;
end;
end;
end;
end;
end;
Searches for ColorA first, and for everywhere that it's found it splits those into boxes, the size of these boxes are defined by the Bounds value you input into the function. Then, it searches inside of each of those boxes for ColorB. If it finds a box in which both colors are found, it'll get the middle point (this will probably exactly where the two colors merge) and move the mouse to that position, at which it'll check for the UpText (any one of the uptexts in the array).
For example:
Simba Code:
//Tolerance of 15 for both colors, box size of 20x20, start the search at the mainscreen center X & Y, color debuggin is false
if FindObjEx_F(RockColor_Ore, RockColor_Base, 15, 20, MSCX, MSCY, ['Mine', 'Rocks'], X, Y, False) then
begin
Writeln('Found a rock at point('+IntToStr(X)+', '+IntToStr(X));
end;