Continuously monitoring parent while loop

Asked by William Wilkins

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:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
William Wilkins (enduserstudios) said :
#1

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.

Revision history for this message
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

Revision history for this message
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

Revision history for this message
RaiMan (raimund-hocke) said :
#5

needs to be clarified

Revision history for this message
William Wilkins (enduserstudios) said :
#6

@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)

Revision history for this message
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.