Skip to content

Instantly share code, notes, and snippets.

@arwankhoiruddin
Created July 30, 2019 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arwankhoiruddin/b3b903bdddda1ccad887dda62a9db7b8 to your computer and use it in GitHub Desktop.
Save arwankhoiruddin/b3b903bdddda1ccad887dda62a9db7b8 to your computer and use it in GitHub Desktop.
Screen capture image using Sikuli and Robot
import java.awt.image.BufferedImage;
import java.io.File;
import org.sikuli.script.Screen;
import org.sikuli.script.ScreenImage;
import javax.imageio.ImageIO;
public class CaptureSikuli {
public static void main(String[] args) throws Exception {
capture("/Users/arwankhoiruddin/Documents/coba.png");
}
public static void capture(String imgPath) throws Exception {
Screen s = new Screen(0);
ScreenImage img = s.capture();
BufferedImage image = img.getImage();
ImageIO.write(image, "png", new File(imgPath));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment