Question

Alright guys, I´ve got here a little problem. Today, I started with Python and I already created a script that saves my work. The problem is, that it exits with code 0 (yeah, I know that it means everything went great). This one however, for some reason shows up BEFORE the script is actually executed (presicely during the execution). It ends just randomly (doesn´t end after a specific time or on a specfic line of code). It worked, before I added an argument "time" to "exists". I don´t really get what´s the matter. Any ideas? The faulty code is below:

import random
targetX="498"
targetY="335"
count=0

def utok():
    click("1372278608978.png")
    if exists("1372280914930.png", 0.5):
        exit()
    else:
        if exists("1372277271552.png", 0.5) or exists("1372278898924.png", 0.5):
            time.sleep(random.uniform(0.2, 0.6))
            click("1372278851129.png")
        else:
            click("1372278963975.png")
            wait("1372279043731.png")
            time.sleep(random.uniform(0.2, 0.5))
            click("1372278851129.png") 
            global count
            count=count+1

def utoceni():
    global count
    count = 0
    while count < 20:
        click("1372277963474.png")
        click("1372282694397.png")
        time.sleep(random.uniform(0.5, 1.2))
        utok()


def prvniutok():
    global count
    count = 0
    while count < 1:
        click("1372277963474.png")
        time.sleep(random.uniform(0.5, 1))
        paste("1372280783030.png", targetX)
        time.sleep(0.1)
        paste(targetY)
        time.sleep(random.uniform(0.7, 1.5))
        utok()

prvniutok()
utoceni()

Thanks for your answers, Dominik. :)

Was it helpful?

Solution

Line 9, has a call to "exit()" if the file exists. Maybe the file it's looking for exists, so it exits the program.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top