Cazax
03-12-2008, 12:06 AM
My first TPA function :)
function FindObjTPAEx(var x,y : Integer; Color,Tol,CTS,ObjWidth,ObjHeight,MinPoints : Integer; UpText : String; x1,y1,x2,y2 : Integer) : Boolean;
var
fx,CurrentCTS,yx,i,a,b : Integer;
Points : TPointArray;
PointsEx : T2DPointArray;
begin
CurrentCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(CTS);
a := GetSystemTime;
FindColorsSpiralTolerance(fx, yx, Points, Color, x1, y1, x2, y2, Tol)
if Length(Points) < MinPoints then
begin
PointsEx := TPAToATPAEx(Points, ObjWidth, ObjHeight);
for i:=0 to Length(PointsEx)-1 do
begin
if Length(Points) < MinPoints then
MiddleTPAEx(PointsEx[i], fx, yx);
MMouse(fx, yx, 5, 5);
if IsUpText(UpText) then
begin
GetMousePos(x,y);
Result := True;
ColorToleranceSpeed(CurrentCTS);
b := GetSystemTime - a;
Writeln('Finding Obj took : '+inttostr(b)+' msecs');
end else
Result := False;
ColorToleranceSpeed(CurrentCTS);
end;
end else
Result := False;
ColorToleranceSpeed(CurrentCTS);
end;
function FindObjTPAEx(var x,y : Integer; Color,Tol,CTS,ObjWidth,ObjHeight,MinPoints : Integer; UpText : String; x1,y1,x2,y2 : Integer) : Boolean;
var
fx,CurrentCTS,yx,i,a,b : Integer;
Points : TPointArray;
PointsEx : T2DPointArray;
begin
CurrentCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(CTS);
a := GetSystemTime;
FindColorsSpiralTolerance(fx, yx, Points, Color, x1, y1, x2, y2, Tol)
if Length(Points) < MinPoints then
begin
PointsEx := TPAToATPAEx(Points, ObjWidth, ObjHeight);
for i:=0 to Length(PointsEx)-1 do
begin
if Length(Points) < MinPoints then
MiddleTPAEx(PointsEx[i], fx, yx);
MMouse(fx, yx, 5, 5);
if IsUpText(UpText) then
begin
GetMousePos(x,y);
Result := True;
ColorToleranceSpeed(CurrentCTS);
b := GetSystemTime - a;
Writeln('Finding Obj took : '+inttostr(b)+' msecs');
end else
Result := False;
ColorToleranceSpeed(CurrentCTS);
end;
end else
Result := False;
ColorToleranceSpeed(CurrentCTS);
end;