pause sikuli until another finish

Asked by aorior

Hi everybody,
I've a question,
I would like to pause a sikuli program in order to execute an other and when it finishes, I would like than the firt resumes.
I suppose this solution works:
Execute the second and make a popup ("done") at the end, and in the first script, wait this popup.
But does another solution exist, easier and without popup?
I begin in sikuli, so I apologize if my question is stupid...
Excuse me for my english, It's not my language!
Aorior.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#2

if you know the places, where the second scipt should run, the the easiest (and fastest) way is to put the complete code of the second script into a def (function) and call it when needed.

# second script now:
click()
wait
# and more

# second script as def (named second.sikuli)
from sikuli import *
def runScript():
    click()
    wait()
    # and more

as you can see, after the def line all lines have to be indented once (select all lines and press tab)
see faq 1800 about indentation

# your first script now:
import second
# now your existing code
second.runScript() # this will execute your second code and come back when finished

Take care: all images in both scripts must have different filenames if they are different (no problem if you leave the automatic naming as timestamp)

about this solution:
http://sikulix-2014.readthedocs.org/en/latest/globals.html#importing-other-sikuli-scripts-reuse-code-and-images
especially: use reload() if you are changing second in IDE while running the main script in the same IDE session.

Revision history for this message
aorior (quentin26om) said :
#3

Thanks RaiMan, that solved my question.

Revision history for this message
aorior (quentin26om) said :
#4

Perfect! Thanks and how quickly you are!
That's exactly the solution I looked for.
I hadn't think about function...