2017-09-20 3 views
0

の作品ではないこれはswitch_to_apps.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)) 

という名前sikuliスクリプトで、私は別のスクリプト(メインスクリプト)にこのスクリプトをインポートして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は私が言う:

私が最初に switch_to_apps.sikuliスクリプトおよび実行機能 go_to_apps()を開いた場合

[エラー] NameErrorその機能の仕上げ作業の後、私はメインの実行、

(名 'go_to_appsは' が定義されていません)スクリプトと今すべての作品。

インポートしたスクリプトの関数が正しく機能する必要がありますか?

+0

クラス内でdefenitionがgo_to_apps()ですか? – Tenzin

+0

いいえ、クラスに含まれていません... – Alexandr

答えて

0

from switch_to_apps import *を使用し、import switch_to_appsを使用しない場合があります。
またはswitch_to_apps.go_to_apps()、おそらくgo_to_apps()ではありません。

私はクラスで私の定義を持っているので、それは私が考える定義を失う少し異なるかもしれません。

+0

まさに! 'from switch_to_apps import *'が動作します!ありがとうございました – Alexandr