西库里
public static void screenClipUser() throws IOException{
org.sikuli.script.Screen screen = Screen.getPrimaryScreen();
org.sikuli.script.Region region = screen.selectRegion("Select Area to capture as Image");
ScreenImage clip = region.getLastScreenImage(); // screen.userCapture();
ScreenImage printScreen = region.getScreen().capture();
javax.imageio.ImageIO.write(clip.getImage(), "PNG", new File("D:\\SikuliImages\\Clip.png"));
ImageIO.write(printScreen.getImage(), "PNG", new File("D:\\SikuliImages\\PrintScreen.png"));
screenCaptureRegion(screen);
}
public static void screenCaptureRegion(Screen screen) throws IOException{
java.awt.Point point = MouseInfo.getPointerInfo().getLocation();
System.out.println("Mouse Location Co-Ordinates Previous Selected : " + point);
//ScreenImage capturedRegion = screen.capture(point.x, point.y, 200, 200);
ScreenImage capturedRegion = screen.capture(clip.x, clip.y, clip.w, clip.h);
ImageIO.write(capturedRegion.getImage(), "PNG", new File("D:\\SikuliImages\\CapturedRegion.png"));
}
西库利克斯
public static void screenClipOneNote(){
org.sikuli.script.IScreen scr = null;
org.sikuli.script.EventObserver ob = null;
final OverlayCapturePrompt oc = new org.sikuli.script.OverlayCapturePrompt(scr, ob);
oc.prompt("Select Area to capture as Image");
oc.addObserver(new org.sikuli.script.EventObserver() { // Inner calss
@Override
public void update(org.sikuli.script.EventSubject arg0) {
org.sikuli.script.ScreenImage capturedImg = oc.getSelection(); // To use oc object make as final.
try {
ImageIO.write(capturedImg.getImage(), "PNG", new File("D:\\SikuliImages\\ScreenClip.png"));
} catch (Exception e) { e.printStackTrace(); }
}
});
}