【发布时间】:2018-03-01 15:40:53
【问题描述】:
这是名为 switch_to_apps.sikuli
的 sikuli 脚本中的函数def go_to_apps():
if exists(Pattern("1505400746884.png").similar(0.85)):
click(Pattern("1505400746884.png").similar(0.85))
wait(2)
if exists("1505400452627.png"):
wait("1505746343759.png",FOREVER)
click("1505745789021.png")
else:
click(Pattern("1505401581163.png").similar(0.95))
else:
click(Pattern("1505400343997.png").similar(0.80))
if exists("1505400452627.png"):
wait("1505746343759.png",FOREVER)
click("1505745789021.png")
else:
click(Pattern("1505401581163.png").similar(0.95))
我将此脚本导入另一个脚本(主脚本)并调用函数go_to_apps()
type("r", Key.WIN)
wait(1)
type ("***************" + Key.ENTER)
wnd= App ("*********.exe")
while not wnd.isRunning():
wait(1)
if exists(Pattern("1505813384072.png").similar(0.85)):
pass
else:
popup("ERROR")
import switch_to_apps
go_to_apps()
wait (5)
rightClick(Pattern("1504795371766.png").similar(0.80))
wait(1)
click(Pattern("1504795615700.png").targetOffset(-75,80))
但 IDE 说我:
[error] NameError(名称'go_to_apps'未定义)
如果我首先打开 switch_to_apps.sikuli 脚本并运行函数 go_to_apps(),在该函数完成工作后,我运行主脚本,现在一切正常。 p>
我需要这样做,我的导入脚本中的函数可以正常工作吗?
【问题讨论】:
-
那个定义
go_to_apps()在课堂上吗? -
不,不在课堂上……