我對sikuli很陌生,並試圖簡單點擊圖片截圖,這對我來說已經成爲一門火箭科學。爲什麼sikuli腳本不能點擊圖片?
僅供參考 - 我截取了google徽標並將其保存在我的機器上。但是,如果我獲取實際的Google徽標圖片網址,則該腳本可以正常工作。
這是使用圖像截圖的正確方法嗎?
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());
}
}
什麼是你看到的錯誤? – Akbar