Sikuli RNG脚本重复相同的数字

时间:2018-11-04 00:22:06

标签: python sikuli

当我将type(str(num))用于随机数时,我会得到一遍又一遍的相同内容:510304296165725

我不确定为什么它会不断重复,因为在脚本开始循环之前就已经设置了参数。我找不到适合的代码,但缩进正确。

running = True
def runHotkey(event):
    global running
    running = False
import random
num = random.randrange(000000000000000,999999999999999)
Env.addHotkey(Key.F1, KeyModifier.CTRL, runHotkey)

while exists(Pattern("1495843225731.png").similar(0.10)) and running:


    if exists(Pattern("1541289046943.png").similar(0.71)):
  DoubleClick(Pattern("1541289689152.png").similar(0.90).targetOffset(-39,3))
        wait(1)
        type(str(num))        
        type(Key.ENTER)
        wait(1)

else:
    wait(1)
    click(Pattern("1541289841740.png").similar(0.82))
    wait(1)
    type("1.wav")
    type(Key.ENTER)

1 个答案:

答案 0 :(得分:0)

想通了!!该脚本将在运行之前标识给定循环要使用的随机数。我将导入随机数放在循环的开头,每次生成一个新的随机数。感谢您的帮助。.这里是

running = True
def runHotkey(event):
    global running
    running = False
Env.addHotkey(Key.F1, KeyModifier.CTRL, runHotkey)

while exists(Pattern("1495843225731.png").similar(0.10)) and running:
    import random
    num = random.randrange(000000000000000,999999999999999)



if exists(Pattern("1541289046943.png").similar(0.71)):
    doubleClick(Pattern("1541289689152.png").similar(0.90).targetOffset(-39,3))
    wait(1)
    type(str(num))        
    type(Key.ENTER)
    wait(1)

else:
    wait(1)
    click(Pattern("1541289841740.png").similar(0.82))
    wait(1)
    type("1.wav")
    type(Key.ENTER)