K, This is what I have mormonman
SCAR Code:
//This is my clicking procedure.
ColorPoints := FindCPoints(5798020,20,Point(Msx1,MSY1),Point(Msx2,MSY2));
SecondaryPoints := FindCPoints(12046035,28,Point(Msx1,MSY1),Point(Msx2,MSY2));
FilteredPoints := FilterPoints(ColorPoints,SecondaryPoints,30);
LeverPoints := PointsInArray(ColorPoints,FilteredPoints);
Iss := random(length(FilteredPoints));
wait(5000+random(400));
mouse(FilteredPoints[Iss].x,FilteredPoints[Iss].y,0,0,true);
Function FilterPoints(TPA1,TPA2:TPointArray;distance:Integer):TPointArray;
var
I, D, Distances : Integer;
Temppoint1,Temppoint2 : TPoint;
begin
setlength(result,0);
for i := 0 to high(TPA1)do
begin
Temppoint1 := TPA1[I];
For D :=0 to high(TPA2)do
begin
TempPoint2 := TPA2[D];
Distances := Iabs(temppoint2.x-temppoint1.x);
Distances := Distances + (Iabs(temppoint2.y-temppoint1.y));
if(Distances<Distance)then
begin
setlength(result, Length(Result)+ 1);
result[high(result)] := Temppoint1;
setlength(result, Length(Result)+ 1);
result[high(result)] :=Temppoint2;
end;
end;
end;
end;
Function PointequalPoint(Point1,Point2:TPoint):boolean;
begin
If(Point1.x=Point2.x)then
result := Point2.y=Point1.y;
end;
Function PointsInArray(Points, ArrayToCheck: TPointArray): TPointArray;
Var
I, D : integer;
Temp1,Temp2 : Tpoint;
begin
setlength(Result,0);
for I := 0 to high(Points)do
begin
Temp1 := Points[I];
For D := 0 to High(ArrayToCheck)do
begin
Temp2 := ArrayToCheck[D];
If(PointequalPoint(Temp1,Temp2))then
begin
setlength(result, Length(Result)+ 1);
result[high(result)] := Temp1;
end;
end;
end;
end;
It works 100% now, but now it is really slow, takes 20+ seconds to filter + check. How can I make this faster???