I have a simple SikuliX script that I'm using to automate some simple testing tasks on a game. The script is just a infinite while loop that makes some clicks and drag/drop some stuff on the screen. It runs normally but sometimes, for no reason apparently, it stops running. Sometimes it runs for hours sometimes it lasts only 5 minutes. The whole code is just that:
def mandaMagia(magia):
type(Key.ENTER)
sleep(0.1)
type(magia)
sleep(0.1)
type(Key.ENTER)
sleep(0.1)
def danca():
type(Key.DOWN, Key.CTRL)
sleep(0.2)
type(Key.UP, Key.CTRL)
sleep(0.1)
def reloadStn():
pos1 = Location(3136,260)
pos2 = Location(3136,450)
dragDrop(pos2, pos1)
sleep(0.2)
def alimentarC1():
rightClick(Location(3136,510))
sleep(0.2)
def alimentarC2():
rightClick(Location(2185,450))
sleep(0.2)
def alimentarC3():
rightClick(Location(1216,460))
sleep(0.2)
def loopPrincipal():
dancaCounter = 0
while 1:
try:
alimentarC2()
mandaMagia("s2")
danca()
alimentarC3()
mandaMagia("s3")
danca()
alimentarC1()
reloadStn()
mandaMagia("s1")
danca()
sleep(0.3)
except:
print('Exception thrown')
loopPrincipal()
print('script end')
When the script stops, I check the sikulx IDE to see it there is any exception thrown but there isn't. I also check in the terminal, since I run it with the command java -jar sikulixide-2.0.4.jar
but also see no error message. What can be wrong here? Why doesn't the loop just run indefinitely? Thanks in advance.
EDIT So I've put these two print messages, one in the except block and other after the loop end and noticed that when the error happens none of these messages are printed, I still have no idea what else to do to find out what's happening. I noticed that most (but not all) the times that it happens is just afther running the type(Key.DOWN, Key.CTRL)
/type(Key.UP, Key.CTRL)
commands.