2013-04-08 71 views
0

這裏循環語法是如何才能做到在Java中相同的Sikuli腳本Sikuli而在Java

while (exists("OK.png"),10): 
    click("OK.png") 

的例子嗎?

這裏是我的嘗試:

Screen screen = new Screen(); 
Pattern image = new Pattern("OK.png"); 

while (screen.exists(image)) 
{ 
    screen.click(image); 
} 

但它未能與此異常編譯:

java: SikuliTest.java:29: incompatible types 
found : org.sikuli.script.Match 
required: boolean 

誰能提供正確的語法?

回答

1

根據the documentationexists()如果圖像被匹配,或以其它方式null返回Match對象。試試這個:

while (screen.exists(image) != null) 
+0

Thanks..that工作。 – Praneeth 2013-04-08 20:27:39

0
import org.sikuli.script.FindFailed; 
Screen screen = new Screen(); 

try{ 
    while(screen.exists("OK.png") != null){ 
    screen.click("OK.png"); 
    } 
} 
    catch(FindFailed e){ 
     e.getStackTrace(); 
    }