问题描述
我想创建一个功能至极使用Sikuli功能(如点击,双击,等等,等等)来创建Sikuli其他脚本,使用函数从sikuli一个libary。
I want to create a function wich use Sikuli features (as click, doubleclick, wait, etc) to create other scripts in Sikuli, as a libary using functions from sikuli.
例中的libary文件:
Example in the "libary" file:
def openCalc(self):
doubleClick("imgs\calculator.png")
def closeCalc(self):
click("imgs\clickclose.png")
和在Sikuli IDE中使用它:
And using it in Sikuli IDE:
def testSum(self):
self.openCalc()
type("5+5\n")
type("c",KEY_CTRL)
try:
assert Env.getClipboard()!="10"
except:
self.nop()
self.closeCalc()
我可以做到这一点以某种方式?怎么样?
Can I do that in some way? How?
感谢。
推荐答案
我上面的评论,我们应该总是使用类的地方,我们可以......但回答你的问题达成一致,这里就是这样,你想要做什么 -
I agree with above comment that we should always use class wherever we can... but to answer your question, here is the way to what you want to do -
调用功能文件的 called_fun.sikuli 有 -
Called Function File called_fun.sikuli has -
a = "abc"
def hey():
print(a)
和调用函数(它有任何名称)是 -
And calling function (whatever name it has) is -
import called_fun
called_fun.hey()
只要确保这两个文件都在同一个文件夹中。
Just make sure that both of the files are in the same folder.
让我知道,如果你有这个问题。
Let me know if you have questions on this.
这篇关于如何使Sikuli一个函数在其他Sikuli脚本中使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!