SRL Archive - Research & Development Lounge

How Does This Smell?


TViYH

2008-09-30 17:09:25


program New;
{.include SRL\SRL.scar}

const
ObjectColor = 0;
Tolerance = 5;
ObjectUpText = ''; // MUST BE EXACT!

var
ObjectPoint: TPointArray;

function FindColorsATPASpiralTolerance(Color, Tolerance: Integer; UpText: string): TPointArray;
var
i, Timer: Integer;
tempPoint: TPoint;
tempTPA: TPointArray;
tempATPA: T2DPointArray;
begin
FindColorsSpiralTolerance(MSCX, MSCY, tempTPA, Color, MSX1, MSY1, MSX2, MSY2, Tolerance);
repeat
MarkTime(Timer);
if length(tempTPA)=0 then
begin
Inc(Tolerance);
FindColorsSpiralTolerance(MSCX, MSCY, tempTPA, Color, MSX1, MSY1, MSX2, MSY2, Tolerance);
end;
until((length(tempTPA)>0) or (TimeFromMark(Timer)>=60000));
tempATPA := SplitTPA(tempTPA, 5);
SortATPASize(tempATPA, True);
for i := 0 to High(tempATPA) do
begin
tempPoint := MiddleTPA(tempATPA[i]);
MMouse(tempPoint.x, tempPoint.y, 0, 0);
Wait(250 + Random(150));
if IsUpText(UpText) then
begin
Result[i] := tempPoint;
end;
end;
end;


begin
SetupSRL;
ObjectPoint := FindColorsATPASpiralTolerance(ObjectColor, Tolerance, ObjectUpText);
if Length(ObjectPoint)>0 then
Mouse(ObjectPoint[0].x, ObjectPoint[0].y, 0, 0, True);
end.

Meh? Pretty good to me.

Tell me what I can change.

Cazax

2008-09-30 17:13:21

Mouse(ObjectPoint[0].x, ObjectPoint[0].y, 0, 0, True);
What if it doesnt find anything? you will get a runtime error. Use try/except or if length(objectpoint) > 0 then.

TViYH

2008-09-30 17:31:44

Kthx. Fixed.

Anything else?