Tehmoo
2013-06-11 21:06:32
My problem is not it actually finding the object it finds that perfectly. What it does is finds all of them but moves the mouse to all of them and tries to click all of them. Obviously what I want it to do is to choose one of the ones it finds and clicks it.
I looked at tutorials but I can't seem to put my mind together to figure it out, even if you point me in the right direction than actually doing it for me is just as nice.
I appreciate any help I can get.
I looked at tutorials but I can't seem to put my mind together to figure it out, even if you point me in the right direction than actually doing it for me is just as nice.
I appreciate any help I can get.
function FindObject(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.06, 0.12);
if not(FindColorsTolerance(arP, MineColor, MSX1, MSY1, MSX2, MSY2, 6)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);
for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 10.15) and (X <= 18.75) and (Y >= 12.39) and (Y <= 22.97) and (Z >= 16.87) and (Z <= 31.89) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);
for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
ClickMouse(P.x, P.y, mouse_Left);
if (IsUpText('Mine')) then
begin;
Result := True;
Break;
end;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;
GetMousePos(fx, fy);
end;