Is this wait cycle convoluted?

2 posts in this topic

#1 ·  Posted (edited)

Hi everyone.

I made a wait function which can be utilized in any situation where windows may change, such as opening a program like excel, waiting on a window to pop up, etc. I was just wondering if this code I've devised is way too convoluted for the task, is there a simpler way? or will this suffice.

Func wait($xc1 = 0, $yc1 = 0, $xc2 = 0, $yc2 = 0, $colour = "", $shade = 1, $outWait = 500)
   Global $waited = 0
      tt("We are waiting...")
      wait2($xc1, $yc1, $xc2, $yc2, $colour, $shade)
         If $waited = 0 Then ; if we looked too soon, try again
            wait2($xc1, $yc1, $xc2, $yc2, $colour, $shade)
      Sleep($outWait) ; Give it some time to do something

Func wait2($xc1, $yc1,$xc2, $yc2, $colour, $shade)
   $waited = PixelSearch($xc1, $yc1, $xc2, $yc2, $colour, $shade) ; look here

EDIT: This is the revised code, however my question still stands, would this be a good approach to this kind of function?

Edited by GeeEssBeeEss
Didn't need some of the code due to If statement (some errors as well)

Share this post

Link to post
Share on other sites

I just realized.. if I'm going to use the if statement.. I really don't need the while loop then. lol

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now