← Back to team overview

sikuli-driver team mailing list archive

[Question #680702]: Import Question

 

New question #680702 on Sikuli:
https://answers.launchpad.net/sikuli/+question/680702

Starting here & here:
https://sikulix-2014.readthedocs.io/en/latest/scripting.html?highlight=import%20*
https://answers.launchpad.net/sikuli/+faq/2446

--testpad.sikuli--
from sikuli import *
# the path containing your stuff - choose your own naming
# on Windows
myScriptPath = "D:\\MikE\\Sikuli Scripts"
# all systems (avoids double entries in sys.path)
addImportPath(myScriptPath)
# supposing there is a testpad2.sikuli
import testpad2
reload(testpad2)
from testpad2 import *
setShowActions (True)
# testpad
# Start script with functions
# supposing myLib.sikuli contains a function "def myFunction():"
testpad2.launchNox()
testpad2.openUE()
#
#    
# end of script
exit(1)

--testpad2.sikuli--
# Testing Global Functions
# Launch Nox
def launchNox():
    app = App("D:\\Program Files\\Nox\\bin\\Nox.exe")
    app.open(5) # does the focus as well
    reg = app.window(0)
    if exists("1555433103893.png"):
        hover("1555433103893.png")
    else:
        sleep(0)
#function open UE app (default account)
def openUE():
    wait("1555426342139.png", 60)
    if exists("1555426342139.png"):
        click("1555426342139.png")
    else:
         sleep(0)
    wait("1556061400286.png", 30)
    hover("1556061400286.png")

and I get this error:
[error] script [ testpad ] stopped with error at line --unknown--
[error] Error caused by: Traceback (most recent call last): File "D:\MikE\Sikuli Scripts\testpad.sikuli\testpad.py", line 15, in <module> testpad2.launchNox() File "D:\MikE\Sikuli Scripts\testpad2.sikuli\testpad2.py", line 2, in launchNox app = App("D:\\Program Files\\Nox\\bin\\Nox.exe") NameError: global name 'App' is not defined 

If I comment out line 15 I see this:
[error] script [ testpad ] stopped with error at line --unknown--
[error] Error caused by: Traceback (most recent call last): File "D:\MikE\Sikuli Scripts\testpad.sikuli\testpad.py", line 16, in <module> testpad2.openUE() File "D:\MikE\Sikuli Scripts\testpad2.sikuli\testpad2.py", line 13, in openUE wait("1555426342139.png", 60) NameError: global name 'wait' is not defined 

Still out of my depth, but making steady progress :D (trying to eliminate any repeat code / reuse as much as possible)


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