← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #186440]: How to start more than one script at boot in one sikuli-ide.sh file

 

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

RaiMan posted a new comment:
for this easy version all scripts have too be in one folder

--- running scripts in sequence one after the other

# ---- main.sikuli
import script1
import script2
# ....
import scriptN

# each of the above scripts contain
# ---- scriptN.sikuli
from sikuli import *
click("some-image.png")
# whatever Sikuli coding you want

and run it using
sikuli-ide.sh -r path-to-main.sikuli

--- if you want to run the scripts in parallel
The threading module contains some additional features to implement some locking between the different scripts.
Be aware that running Sikuli scripts in parallel might lead to messing mouse and key board usage up, so the scripts must fit together according this behavior (e.g. triggered by some exclusive image or via a hot-key).

# ---- main.sikuli
import threading

myThreads = []

class RunScript(threading.Thread):
    def __init__(self, script):
        threading.Thread.__init__(self)
        self.script = script
    def run(self):
        exec("import"+self.script)

def doRun(script):
    myThreads.append(RunScript(script))
    myThreads[-1].start()

# start all scripts to run in parallel
doRun("script1")
doRun("script2")
# ....
doRun("scriptN")

# wait for all scripts to terminate
for t in myThreads:
    t.join()

Both above approaches can be combined and enriched with parameter
processing via sys.argv, to get the scripts to run and a loop to
flexibly start the scripts.

The threaded scripts must be able to run standalone.

Hope this was your question ;-)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.