TRiLeZ
2009-09-10 08:47:22
RM suggested for me to make a function to wait until a colour is gone so I made 2.
WaitColorGone and WaitColorGoneIn.
Read their descriptions.
WaitColorGone and WaitColorGoneIn.
{*******************************************************************************
function WaitColorGone(Color, x, y, Tol, MaxTime: integer): Boolean;
By: TRiLeZ
Description: Waits until a colour is gone at (x, y) with tolerance and a timeout.
Results true if the colour disappeared at (x, y) within the time cap.
*******************************************************************************}
function WaitColorGone(Color, x, y, Tol, MaxTime: integer): Boolean;
var
Time: Integer;
begin
Result := False;
if Tol = 0 then Tol := 1;
Time := GetSystemTime + MaxTime;
while (Time > GetSystemTime) do
begin
if (not SimilarColors(GetColor(X, Y), Color, Tol)) then
begin
Result := True;
Exit;
end;
Wait(5 + Random(6));
end;
end;
{*******************************************************************************
function WaitColorGoneIn(Colour, x1, y1, x2, y2, Tol, MaxTime: integer): Boolean;
By: TRiLeZ
Description: Waits until a colour is gone in an area with tolerance and a timeout.
Results true if the colour disappeared in the area within the time cap.
*******************************************************************************}
function WaitColorGoneIn(Colour, x1, y1, x2, y2, Tol, MaxTime: integer): Boolean;
var
Time, CX, CY: Integer;
begin
Result := False;
if Tol = 0 then Tol := 1;
Time := GetSystemTime + MaxTime;
while (Time > GetSystemTime) do
begin
if (not FindColorTolerance(cx, cy, Colour, x1, y1, x2, y2, Tol)) then
begin
Result := True;
Exit;
end;
Wait(5 + Random(6));
end;
end;
Read their descriptions.