How about this:
Code:
function FindObjectCTS(color, w, h, tol, filter: Integer; hmod, smod: Extended): Boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
X, Y, CTS, hm, sm: Integer;
begin
Result := False;
if not ss_LoggedIn then
Exit;
CTS := GetToleranceSpeed;
GetToleranceSpeed2Modifiers(hm, sm);
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(hmod, smod);
FindColorsSpiralTolerance(ss_MS.x, ss_MS.y, TPA, color, ss_MSX1, ss_MSY1, ss_MSX2, ss_MSY2, tol);
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(hm, sm);
if (Length(TPA) > 0) then
begin
ATPA := TPAToATPAEx(TPA, w, h);
FilterTPAsBetween(ATPA, 1, filter);
if (Length(ATPA) > 0) then
begin
SortATPAFromFirstPoint(ATPA, Point(ss_MS.x, ss_MS.x));
MiddleTPAEx(ATPA[0], X, Y);
MMouse(X, Y, 0, 0);
ClickMouse2(mouse_Left);
Result := True;
end;
end;
end;