首页 > 解决方案 > 我正在尝试实现两个新命令,但它们在我的 Sikuli 脚本中被忽略

问题描述

我正在尝试添加两个新行(最后一个“如果存在”和“doubleClick”),但它们没有被识别。

这是我已经拥有的功能:

def do(a, b, ab, abc, ef, efg):
    if not (exists(a, 0) and exists(ab, 0)):
        return

    doubleClick(abc)
    start = time.time()

    while exists(ab, 0):
        wait(0.1)

    while time.time() < (start + 3) and exists(a, 0):
        pass

    if exists(a, 0):
        doubleClick(b)
        return

    #to be implemented, it has been ignored by the function/script. 
    #It should be triggered whenever the img5 appears. 
    #just to be clear, the img5 will only exist if the img1 doesn't exist

    if exists(ef, 0):
        doubleClick(efg)

while True:
    do(a="img1", b="img2", ab="img11", abc="img111", ef="img5", efg="img51")
    do(a="img1", b="img2", ab="img12", abc="img121", ef="img5", efg="img51")

我已经尝试删除退货,添加新通行证,放置新退货,但没有任何效果。

除了我要添加的部分之外,一切都运行顺利。

只是发生了任何事情,该功能忽略了那部分。

谢谢你的帮助。

对于给您带来的任何不便,我深表歉意。

我还在学习如何编码,我是个业余爱好者。

标签: pythonsikulisikuli-scriptsikuli-ide

解决方案


@RaiMan在 SikuliX Q&A 中帮助了我

(解决方案)应该如何:

def do(a, b, ab, abc, ef, efg):
    if not exists(a, 0):
        if exists(ef, 0):
            doubleClick(efg)
            return
        return
    if not exists(ab, 0):
        return

推荐阅读