looping a script forever in Sikulix

Asked by Drex

First of all apologies for asking a question that already exists and answered numerous times but my knowledge of python is 0 i am a ultra noob and i dont understand any of those explanations.

I made a macro for a game with Sikulix and it works fine i just need to loop it forever i need the code that will enable this for my macro.

This is the code i need looped

click("1453202630435.png")
wait(80)
wait("1453736008362.png",10),click("1453736008362.png")
wait("1453202801705.png",25),click("1453202812250.png")
wait(10)
Image1 = ("1453723117924-4.png")
Image2 = ("1453735625632.png")
class Multi():
    def __init__(self):
        self.Search()
    def Search(self):
        # Look when one of the two images appear.
        while True:
            print('Searching....')
            if exists("1453723117924-5.png"):
                print("1453723117924-6.png")
                click("1453723117924-7.png")
                # Break loop.
                break
            elif exists("1453735625632.png"):
                print("1453735625632.png")
                click("1453735625632.png")
                # Break loop.
                break
            else:
                pass
# Run class
Multi()
wait("1453202882292.png",20),click("1453202898972.png")

Im sure its crude and can be refined but im happy with it like a childs first drawing or something i just need the loop code added to this so i can see it and copy it, explaining it wont help as im too dumb at the moment to understand i am trying to learn basic python but will be a while before im able to understand any of it any help much appreciated.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Karl (k-d) said :
#1

while True:
    click("1453202630435.png")
    wait(80)
    wait("1453736008362.png",10),click("1453736008362.png")
    wait("1453202801705.png",25),click("1453202812250.png")
    wait(10)
    Image1 = ("1453723117924-4.png")
    Image2 = ("1453735625632.png")
    while True:
        print('Searching....')
        if exists("1453723117924-5.png"):
            print("1453723117924-6.png")
            click("1453723117924-7.png")
            # Break loop.
            break
        elif exists("1453735625632.png"):
            print("1453735625632.png")
            click("1453735625632.png")
            # Break loop.
            break
        else:
            pass
    wait("1453202882292.png",20),click("1453202898972.png")

Revision history for this message
Drex (kaizer1410-deactivatedaccount) said :
#2

wow thanks i have tried everything but couldnt get that to loop now i see i was not even close it looks much cleaner now and it does loop, one more issue i forgot to post the whole code theres a second part in the end that may show up at any time when energy is depleted and this will auto refill i couldnt figure out how to insert it into your looped version it has to click 4 images if image 1 pops up at the end after wait("1453202882292.png",20),click("1453202898972.png") is clicked then go back to clicking wait("1453202882292.png",20),click("1453202898972.png") and continue this is how i managed to get that work using the multi code section in the middle which i found online

Image1 = ("1454598106549.png")
Image2 = ()
class Multi():
    def __init__(self):
        self.Search()
    def Search(self):
        # Look when one of the two images appear.
        while True:
            print('Searching....')
            if exists("1454598167955.png"):
                print("1454598182139.png")
                click("1454598192421.png")
                # Break loop.
                break
            elif exists():
                print()
                click()
                # Break loop.
                break
            else:
                pass
# Run class
Multi()
Image1 = ("1454598132644.png")
Image2 = ()
class Multi():
    def __init__(self):
        self.Search()
    def Search(self):
        # Look when one of the two images appear.
        while True:
            print('Searching....')
            if exists("1454598132644.png"):
                print("1454598132644.png")
                click("1454598132644.png")
                # Break loop.
                break
            elif exists():
                print()
                click()
                # Break loop.
                break
            else:
                pass
# Run class
Multi()
Image1 = ("1454598106549.png")
Image2 = ()
class Multi():
    def __init__(self):
        self.Search()
    def Search(self):
        # Look when one of the two images appear.
        while True:
            print('Searching....')
            if exists("1454598106549.png"):
                print("1454598106549.png")
                click("1454598106549.png")
                # Break loop.
                break
            elif exists():
                print()
                click()
                # Break loop.
                break
            else:
                pass
# Run class
Multi()
Image1 = ("1454598655650.png")
Image2 = ()
class Multi():
    def __init__(self):
        self.Search()
    def Search(self):
        # Look when one of the two images appear.
        while True:
            print('Searching....')
            if exists("1454598655650.png"):
                print("1454598655650.png")
                click("1454598655650.png")
                # Break loop.
                break
            elif exists():
                print()
                click()
                # Break loop.
                break
            else:
                pass
# Run class
Multi()

thank you for the quick reply and help i have been at this for a week now with no progress

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