简体   繁体   中英

use a function from other sikuli script

I have one scripts say main.sikuli which is used in below script:--

from main.sikuli import *
class TestsMain(unittest.TestCase):

   def setUp(self): 

       wait(2)
       click("pica.png")
   def tearDown(self):


       if exists("b.png"):
           type(Key.F4,KeyModifier.CTRL)



   def testa(self):

       #function body
       main.testb(self)

where testb is a function in main.sikuli, but this does not work.

Please advise.

From https://stackoverflow.com/questions/5806383/calling-sikuli-from-cpython :

According to the Sikuli documentation it is not possible to run the .py files generated by Sikuli with CPython since it is domain-specific Jython code. Just the syntax is Python. If you just need to call the script, a (silly) solution is described in https://answers.launchpad.net/sikuli/+question/131729 :

    import subprocess
    import sys

    def RunSikuliScript(sikuliscriptname):
     subprocess.Popen('"C:\Program Files\Sikuli\Sikuli-ide.exe" -r ' + sikuliscriptname, shell=True)

    if __name__ == '__main__':
      RunSikuliScript(sys.argv[1])

tl;dr: you should probably use Jython

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM