← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #673647]: How would I stop a while loop after n amount of time?

 

Question #673647 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/673647

    Status: Open => Answered

RaiMan proposed the following answer:
something like that:

stop = time.time() + 20
reason = ""

while not exists(A.png): #A.png=9999
    mouseMove(B.png) #B.png=PLUS
    mouseDown(Button.LEFT)
    if time.time() > stop:
      reason = "timeout"
      break
else:
    reason = "check"
mouseUp()
if not reason == "":
  print "reason =", reason
  # do some error handling

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.