Sunblood 1 Posted February 12, 2004 Share Posted February 12, 2004 What I want my script to do is wait until a certain pixel is a certain color, but timeout the search after 5 seconds. Waiting for a pixel I can do, and I have this: Func PixelColor(ByRef $xcoord, ByRef $ycoord, ByRef $pixelcolor) Do $pixel = PixelGetColor($xcoord,$ycoord) Until $pixel = $pixelcolor EndFunc But I want it to stop searching after, say, 5 seconds. I tried: Do $timer = TimerStart() $pixel = PixelGetColor($xcoord,$ycoord) $dif = TimerStop($timer) Until $pixel = $pixelcolor OR $dif > 2000 But that just restarts the timer every time. Help? Please? Link to post Share on other sites
GrahamS 0 Posted February 12, 2004 Share Posted February 12, 2004 You need to move the timer start outside the do loop i.e. $timer = TimerStart() Do $pixel = PixelGetColor($xcoord,$ycoord) $dif = TimerStop($timer) Until $pixel = $pixelcolor OR $dif > 2000 GrahamS Link to post Share on other sites
Sunblood 1 Posted February 12, 2004 Author Share Posted February 12, 2004 (edited) Won't that start the timer outside the loop, then try to stop the timer over and over? *tries it out* EDIT: Whoahey. It works! Thanks, GrahamS. Edited February 12, 2004 by Sunblood Link to post Share on other sites
GrahamS 0 Posted February 12, 2004 Share Posted February 12, 2004 Won't that start the timer outside the loop, then try to stop the timer over and over?*tries it out*EDIT: Whoahey. It works!The function seems to be misnamed. The documentation statesReturns a difference in time from a previous call to StartTimer().Nothing about actually stopping the timer. In fact, although I haven't inspected the code, I reckon that TimerStart just stores the machine's current time and TimerStop does a simple subtraction Thanks, GrahamS.You're welcome GrahamS Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now