SRL Archive - SRL Archives

FindObjectTPAEx


TViYH

2008-09-27 20:32:37


function vFindObjectTPAEx(x, y, width, height, color, tolerance, xs, ys, xe, ye:
integer; UpText: string): Boolean;
var
cX, cY, i: integer;
TempTPA: TPointArray;
TempATPA: T2DPointArray;

begin
Result := False;
FindColorsSpiralTolerance(x, y, TempTPA, color, xs, ys, xe, ye, tolerance);
if Length(TempTPA) = 0 then
begin
FindColorsSpiralTolerance(x, y, TempTPA, color, xs, ys, xe, ye, Tolerance + 10);
if Length(TempTPA) = 0 then
begin
WriteLn('Color not found, please use a better color.');
Exit;
end;
end;
TempATPA := SplitTPAEx(TempTPA, width, height);
SortATPASize(TempATPA, True);
for i := 0 to High(TempATPA) do
begin
MiddleTPAEx(TempATPA[i], cX, cY);
MMouse(cX, cY, 6, 6);
Wait(140 + random(170));
if Pos(RS_GetUpText, UpText) > 0 then
begin
GetMousePos(cX, cY);
Mouse(cX, cY, 0, 0, True);
Result := True;
Exit;
end else
Continue;
end;
end;

Finds a TPA using the provided info, sorts it into ATPAs, then uses MiddleTPA to check the point if it finds the UpText.

EvilChicken!

2008-09-27 20:45:30

What if it doesn't find any colors the second time?

And, the UpText check should be IN the function.

Otherwise looks really nice. (y)

TViYH

2008-09-27 21:24:24

I don't think the UpText should be in the function.

What if they aren't looking for the uptext?

noidea

2008-09-27 21:36:52

Do like,
MMouse(?,?,4,4)
if isuptext(Uptext) then
begin
Getmousepos(x,y)
exit;
end;

TViYH

2008-09-27 21:51:53

But how would I store that into the Result's TPA?

Nava2

2008-09-28 01:20:05

You should add the uptext check, as it is an object finder. :)

TViYH

2008-09-28 17:30:11

But how would I make it check the UpText, and if it returns true, add that point to the Result's TPA?

EvilChicken!

2008-09-28 21:56:16

function vFindObjectTPAEx(x, y, width, height, color, tolerance, xs, ys, xe, ye:
integer; UpText: string): Boolean;
var
cX, cY, i: integer;
TempTPA: TPointArray;
TempATPA: T2DPointArray;

begin
Result := False;
FindColorsSpiralTolerance(x, y, TempTPA, color, xs, ys, xe, ye, tolerance);
if Length(TempTPA) = 0 then
begin
FindColorsSpiralTolerance(x, y, TempTPA, color, xs, ys, xe, ye, Tolerance + 10);
if Length(TempTPA) = 0 then
begin
WriteLn('Color not found, please use a better color.');
Exit;
end;
end;
TempATPA := SplitTPAEx(TempTPA, width, height);
SortATPASize(TempATPA, True);
for i := 0 to High(TempATPA) do
begin
MiddleTPAEx(TempATPA[i], cX, cY);
MMouse(cX, cY, 6, 6);
Wait(140 + random(170));
if Pos(RS_GetUpText, UpText) > 0 then
begin
GetMousePos(cX, cY);
Mouse(cX, cY, 0, 0, True);
Result := True;
Exit;
end else
Continue;
end;
end;


You mean somehting like this?

(Warn: untested, and I wrote this at ..
/looks a clock. Wow. 4 AM, time passes by fast >: )

Anyway, you should add support for color arrays, otherwise you've done a good job.

rep+ :D

TViYH

2008-09-28 21:59:49

Hmmm. Very good. Can I use that?

EvilChicken!

2008-09-28 22:01:34

From: TheVoiceInYourHead
Hmmm. Very good. Can I use that?



It would make my day, sir.