Pmh1000
2007-04-08 16:53:16
I used this a lot when trying to wait to know when to click the next option or to wait until the menu to type in how much of an item to cut or withdraw etc… basically the way this function works is that It will either wait until it finds a certain color at Point (x,y) or until the color at point (x,y) disappears. ( you set whether it will wait for the color to appear or disappear with the DoOrNot boolean) Once it finds the color it waits the Time specified to wait (AfterFound ) . If it reaches the KillTime Then it breaks the wait and it moves on as if it has found the color or the color has disappeared. (a Fail Safe)
EXAMPLE:
WaitUntill(219,394,0,3500,400,True)
It waits until it finds the color '0' (because DoOrNot is set to true ) at point (219,394). Once it finds that Color It waits 400 milliseconds (it also waits an extra +Random(200)) If it waited to find the color for 3500 milliseconds then it breaks out of the procedure and moves on as if it found the color.
{*******************************************************************************
/////////////////////////////////WaitUntill/////////////////////////////////////
*******************************************************************************}
{*******************************************************************************
Procedure WaitUntill(x :integer; y :integer; Color :integer; KillTime:integer; Afterfound:integer; DoOrNot:Boolean);
Original code by: Pmh1000
Description: Waits Until IT Gets The 'Color' And Point X And Y.
Description Of Vars:
X: X Point Of The Color;
Y: Y Point Of The Color;
Color: The Color That Is Found At Point (X,Y);
KillTime: Maximum Time To Wait To Find The Color Before It Breaks The Procedure;
AfterFound: Time To Wait After It Finds The Color Or Breaks Due To Killtime Reached, Usually Between 300-800;
DoOrNot: True To Wait Untill It Finds The Color, False To Wait Until The Color Disappears!
*******************************************************************************}
Procedure WaitUntill(x :integer; y :integer; Color :integer; KillTime:integer; Afterfound:integer; DoOrNot:Boolean);
var WaitMark :integer;
begin
MarkTime(WaitMark)
Repeat
Wait(200+random(100))
If ((DoORNot=True) and (GetColor(x, y)=Color)) Then Break;
If ((DoORNot=False) and (Not(GetColor(x, y)=Color))) Then Break;
Until(TimeFromMark(WaitMark)>KillTime)
Wait(AfterFound+random(200))
end;
EXAMPLE:
WaitUntill(219,394,0,3500,400,True)
It waits until it finds the color '0' (because DoOrNot is set to true ) at point (219,394). Once it finds that Color It waits 400 milliseconds (it also waits an extra +Random(200)) If it waited to find the color for 3500 milliseconds then it breaks out of the procedure and moves on as if it found the color.
{*******************************************************************************
/////////////////////////////////WaitUntill/////////////////////////////////////
*******************************************************************************}
{*******************************************************************************
Procedure WaitUntill(x :integer; y :integer; Color :integer; KillTime:integer; Afterfound:integer; DoOrNot:Boolean);
Original code by: Pmh1000
Description: Waits Until IT Gets The 'Color' And Point X And Y.
Description Of Vars:
X: X Point Of The Color;
Y: Y Point Of The Color;
Color: The Color That Is Found At Point (X,Y);
KillTime: Maximum Time To Wait To Find The Color Before It Breaks The Procedure;
AfterFound: Time To Wait After It Finds The Color Or Breaks Due To Killtime Reached, Usually Between 300-800;
DoOrNot: True To Wait Untill It Finds The Color, False To Wait Until The Color Disappears!
*******************************************************************************}
Procedure WaitUntill(x :integer; y :integer; Color :integer; KillTime:integer; Afterfound:integer; DoOrNot:Boolean);
var WaitMark :integer;
begin
MarkTime(WaitMark)
Repeat
Wait(200+random(100))
If ((DoORNot=True) and (GetColor(x, y)=Color)) Then Break;
If ((DoORNot=False) and (Not(GetColor(x, y)=Color))) Then Break;
Until(TimeFromMark(WaitMark)>KillTime)
Wait(AfterFound+random(200))
end;