← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #172860]: While loop

 

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

    Status: Open => Answered

Harry Readinger proposed the following answer:
A few things from my experience:

1) try limiting your find/exists to a region if possible and just
observe that region.  For example take a screenshot of your system tray
(sysTray.png) and try this before the loop:

st = find("sysTray.png")
str = Region(st)

That makes a Region on the rectangle returned from the find().  doing
find/exists in this region will be MUCH faster, and possibly fix your
problem.

SO you can then just adapt your code like this:

st = find("sysTray.png")
str = Region(st)

setAutoWaitTimeout(FOREVER)

while(1):
    while not str.exists("1317412001875.png"):
        sleep(0.5)

    popup("Internet connection has been lost.")
    str.wait("5.png")
    popup("Negotiating with server...")
    str.wait("J.png")
    popup("Online.")


2) If that alone doesn't help try not using FOREVER (which personally I have never had work).  To test this try specifying a length of time to wait, say 1 hour:


st = find("sysTray.png")
str = Region(st)


while(1):
    while not str.exists("1317412001875.png"):
        sleep(0.5)

    popup("Internet connection has been lost.")
    str.wait("5.png", 3600)
    popup("Negotiating with server...")
    str.wait("J.png", 3600)
    popup("Online.")


See if either of those help

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.