pythonsikulisikuli-scriptsikuli-ide

I'm trying to implement two new commands but they are being ignored on my Sikuli script


I'm trying to add two new lines (the last "if exists" and "doubleClick") but they are not being recognized.

This is the function I already have:

def do(a, b, ab, abc, ef, efg):
    if not (exists(a, 0) and exists(ab, 0)):
        return

    doubleClick(abc)
    start = time.time()

    while exists(ab, 0):
        wait(0.1)

    while time.time() < (start + 3) and exists(a, 0):
        pass

    if exists(a, 0):
        doubleClick(b)
        return

    #to be implemented, it has been ignored by the function/script. 
    #It should be triggered whenever the img5 appears. 
    #just to be clear, the img5 will only exist if the img1 doesn't exist

    if exists(ef, 0):
        doubleClick(efg)

while True:
    do(a="img1", b="img2", ab="img11", abc="img111", ef="img5", efg="img51")
    do(a="img1", b="img2", ab="img12", abc="img121", ef="img5", efg="img51")

I already tried to remove the return, add a new pass, put a new return, but nothing has been effective.

Everything runs smoothly except the part I'm trying to add.

It's just anything happens, the function is ignoring that part.

Thank you for all your help.

I'm sorry for any inconvenience.

I'm still learning how to code, I'm an amateur.


Solution

  • @RaiMan helped me in the SikuliX Q&A.

    (Solution) How it should be:

    def do(a, b, ab, abc, ef, efg):
        if not exists(a, 0):
            if exists(ef, 0):
                doubleClick(efg)
                return
            return
        if not exists(ab, 0):
            return