Continuously monitoring parent while loop

Asked by William Wilkins on 2018-11-15

I am wonder what is the best way to solve my problem.

My current code looks something like this:

while tloop <= minei:
    if exists(image):
        click(image)
        type("stuff" + Key.ENTER)
        wait(4)
        click(image)
    while exists(image):
        while not exists(image):
            if exists(image):
                click(getLastMatch())
            else:
                ()
            wait(21)

What I am trying to achieve is that when the first "while exist(image)" stops existing it will break the loop and start the main loop again no matter were it is currently in the second loop.

Thank for any help!

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2018-11-18
Last reply:
2018-11-19

I guess one solution would be to make the while loops not as strong something like:

while tloop <= minei:
    if exists(image):
        click(image)
        type("stuff" + Key.ENTER)
        wait(4)
        click(image)
    while exists(image):
        if exists(image):
            click(getLastMatch())
        else:
            ()
        wait(21)

This would make it have to loop all the way around when it encounters an error also make the loop counter inaccurate.

masuo (masuo-ohara) said : #2

This is repeats from Loop 1 if an error occurs while processing Loop 2.

[example:]
while True:
    popup("Loop1 start")
    while True:
        popup("Loop2 start")
        try:
            find("1542371485976.png").highlight(1)
            sleep(3)
        except:
            popup("FindFailed")
            break

RaiMan (raimund-hocke) said : #3

not clear what you want:

is image really always the same shot?

if yes:
the logic looks odd and is not clear

if not:
rename the images so we can see what is what

RaiMan (raimund-hocke) said : #5

needs to be clarified

@RaiMan

Thank you for your time.

No they are not. See the new code here:

while tloop <= minei:
    if exists(image1):
        click(image2)
        type("stuff" + Key.ENTER)
        wait(4)
        click(image3)
    while exists(image4):
        while not exists(image5):
            if exists(image6):
                click(getLastMatch())
            else:
                ()
            wait(21)

Jitendra patel (jpatel1011) said : #7

I think you want something like

while exists(image4) and not exists(image5):
    if exists(image6):
        click()
    else:
        ....

or maybe

while exists(image4) and exists(Image6):
    if exists(image5):
        break
    else:
        click(image6)

Can you help with this problem?

Provide an answer of your own, or ask William Wilkins for more information if necessary.

To post a message you must log in.