사실, 훨씬 simpliler 이상 신뢰할 수있는 솔루션이 여기에있다. 자바 응용 프로그램 내에 Sikuli 라이브러리를 구현하여 화면의 이미지 요소를 찾아 내고 상호 작용할 수 있습니다. 그것은 UI 테스트를 자동화하기위한 것이었지만 여러분의 필요를 꽤 쉽게 수용 할 수 있다고 생각합니다.
샘플 응용 프로그램 (source) :
import java.net.MalformedURLException;
import java.net.URL;
import org.sikuli.api.*;
import org.sikuli.api.robot.Mouse;
import org.sikuli.api.robot.desktop.DesktopMouse;
import org.sikuli.api.visual.Canvas;
import org.sikuli.api.visual.DesktopCanvas;
import static org.sikuli.api.API.*;
public class HelloWorldExample {
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");
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.click(r.getCenter());
}
}
또한 설정을위한 How to use Sikuli inside your Java programs를 참조하십시오.
출처
2013-03-19 13:13:06
Noz
하지만 얼마나 빠를까요? 이드는 게임에서 좋은 점수를 얻기 위해 그것을 사용하고 싶지만 .. 모든 것들을 통과하는 것은 영원히 성공하지 못합니까? – Jaanus
사용해보기. 나는 한 번 테트리스 봇을 위해 그것을했습니다 ... 테트리스 필드를 스캔하는 것이 당신의 상황보다 약간 더 쉬울지라도 잘 작동했습니다. – aioobe
얼마나 영리한가에 달려 있습니다. 이진 검색과 같은 일을 할 수있는 방법이있을 수도 있고 다양한 단축키를 사용할 수도 있습니다. 예를 들어 30x30 픽셀의 흰색 사각형을 찾으려면 현재 픽셀이 흰색이 아닌 경우 사각형을 누락시키지 않고 30 픽셀을 건너 뛸 수 있습니다. 그것은 모두 당신이 화면 상에 기대하는 것에 달려 있습니다. – Doug