EDIT: my bad, didnt use the function i had .............. sorry =(
EDIT: my bad, didnt use the function i had .............. sorry =(
If you're using a color search, you can use FindColorsSpiralTolerance to grab all the matching colors, then search through the array of colors backwards. It should work fine, I think.
One of the FindObject type procedures uses FindColorsSpiralTolerance. You can modify that one to search from the end of the color array and try it out.
SCAR Code:{*******************************************************************************
function FindObjTPA(var x, y: integer; color, tol, cts, ObjWidth, ObjHeight, minCount :Integer; UpText: tstringarray): Boolean;
By: Wizzup?
Description: Finds object using WizzyPlugin functions.
Starts with a Spiral from x and y.
Put in the color, Tolerance and ColorToleranceSpeed.
If you don't know what colortolerancespeed to choose, put in -1.
ObjWidth and ObjHeight are the parameters TPAToATPAEx uses, thus filtering
the MS's FindColorsSpiralTolerance points in boxes defined by
ObjWidth and ObjHeigth.
minCount is the amount of colors it should at least find in a Object box.
UpText, is ofcourse the text the object should have. In the Multi variant the
UpText is a string array.
*******************************************************************************}
function FindObjTPA(var x, y: integer; color, tol, cts, ObjWidth, ObjHeight, minCount :Integer; UpText: tstringarray; Closest: Boolean): Boolean;
var
I, j, tcts: Integer;
myPoint: TPoint;
Points: TPointArray;
aPoints: T2DPointArray;
s: string;
begin
tcts := GetColorToleranceSpeed;
if not (cts >= 0) and (cts <= 2) then
cts := 1; // Standard.
ColorToleranceSpeed(cts);
FindColorsSpiralTolerance(x, y, Points, Color, MSX1, MSY1, MSX2, MSY2, Tol);
aPoints := TPAtoATPAEx(Points, ObjWidth, ObjHeight);
If Not Closest Then InvertTPA(aPoints);
SetLength(Points, 0);
for I := 0 to Length(aPoints) - 1 do
begin
if Length(aPoints[I]) < minCount then
Continue;
myPoint := MiddleTPA(aPoints[I]);
MMouse(myPoint.X, myPoint.Y, 0, 0);
Wait(100 + Random(50));
ColorToleranceSpeed(1);
s := rs_getuptext;
for j := 0 to high(uptext) do
if pos(uptext[j], s) <> 0 then
begin
x := myPoint.X;
y := myPoint.Y;
Result := True;
ColorToleranceSpeed(tcts);
Exit;
end;
ColorToleranceSpeed(cts);
end;
ColorToleranceSpeed(tcts);
end;
Added a Closest boolean param, set to true for closest, False for the farest (Sp?).
There are currently 1 users browsing this thread. (0 members and 1 guests)