2013-10-27 2 views
0

나는 sikuli에 완전히 익숙하지 않아 나를위한 로켓 과학이 된 이미지 스크린 샷을 간단히 클릭하려고합니다.sikuli 스크립트가 이미지를 클릭하지 않는 이유는 무엇입니까?

FYI - Google 로고 캡쳐 화면을 내 컴퓨터에 저장했습니다. 그러나 실제 Google 로고 이미지 URL을 가져 오면 스크립트가 작동합니다.

이미지 캡쳐 화면을 사용하는 것이 올바른 방법입니까?

public class TestGenericButton { 
    public static void main(String[] args) throws MalformedURLException { 
     // Open the main page of Google Code in the default web browser 
     browse(new URL("http://code.google.com")); 

     // Create a screen region object that corresponds to the default monitor in full screen 
     ScreenRegion s = new DesktopScreenRegion(); 

     // Specify an image as the target to find on the screen 
     //URL imageURL = new URL("http://code.google.com/images/code_logo.gif"); 
     URL imageURL = new URL("img\\google.gif"); 
     Target imageTarget = new ImageTarget(imageURL); 

     // Wait for the target to become visible on the screen for at most 5 seconds 
     // Once the target is visible, it returns a screen region object corresponding 
     // to the region occupied by this target 
     ScreenRegion r = s.wait(imageTarget,5000); 

     // Display "Hello World" next to the found target for 3 seconds 
     Canvas canvas = new DesktopCanvas(); 
     canvas.addLabel(r, "Hello World").display(3); 

     // Click the center of the found target 
     Mouse mouse = new DesktopMouse(); 
     mouse.rightClick(r.getCenter()); 
    } 
}  
+0

을 수행해야합니다 ? – Akbar

답변

0

아니요, ImageTarget을 만드는 방법이 아닙니다. 사용할 파일에 이미지가 있으므로 URL이 아니라 File을 전달해야합니다. the documentation

대신

URL imageURL = new URL("img\\google.gif"); 
    Target imageTarget = new ImageTarget(imageURL); 

의이

File imageFile = new File("img\\google.gif"); // assumes your working directory is set right... 
    Target imageTarget = new ImageTarget(imageFile); 
0

이 이미지 URL을 제공 할,이 방법은 당신이 볼 수있는 오류는 무엇 클릭 부분 :

private void click(String image) throws FindFailed{ 

    Screen screen = new Screen(); 

    Pattern pattern = new Pattern(image).similar((float) 0.7); 

    if(screen.find(pattern)!=null){ 
     screen.mouseMove(pattern); 
     screen.click(pattern); 
    } 
    }