← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #292921]: How to make a "bridge" to 2 or 3 script

 

Question #292921 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/292921

    Status: Open => Answered

Roman Podolyan proposed the following answer:
It's possible, but you need better code.


1) You have to make you scripts functions (learn it —  http://www.tutorialspoint.com/python/python_functions.htm ) 
2) You have to learn try .. catch thing, allowing to handle exceptions  ( https://docs.python.org/2/tutorial/errors.html ) , in particular 
Exception FindFailed ( http://doc.sikuli.org/region.html#exception-findfailed ) 
3) Every script should be transformed in "try ... except" 

then you put something like this

def script1():
    try:
        ...
        ... 
        retun False
   except FindFailed: 
        return true  

def script2():
    ...
    ...


def script3():
    ...
    ...


while True:
   flag = script1()
   if flag : 
         script2(); 
         script3();  
         flag = false


That is: 
1) script1 returns False if no error with finding images, and True otherwise 
2) script2() and script3() get executed only if flag is true, and then loop again starts from script1().

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.