function takeSnapshot(filepath) {
try {
var robot = new java.awt.Robot();
var toolkit = new java.awt.Toolkit.getDefaultToolkit();
var screenSize = toolkit.getScreenSize();
var screenRect = new java.awt.Rectangle(0, 0, screenSize.width, screenSize.height);
var image = robot.createScreenCapture(screenRect);
var file = new java.io.File(filepath);
javax.imageio.ImageIO.write(image, "png", file);
} catch (e) {
print(e);
}
}
try {
var robot = new java.awt.Robot();
var toolkit = new java.awt.Toolkit.getDefaultToolkit();
var screenSize = toolkit.getScreenSize();
var screenRect = new java.awt.Rectangle(0, 0, screenSize.width, screenSize.height);
var image = robot.createScreenCapture(screenRect);
var file = new java.io.File(filepath);
javax.imageio.ImageIO.write(image, "png", file);
} catch (e) {
print(e);
}
}
保存ファイルを指定してスクリーンショットを取得する.
var filepath = "C:/home/hy/sahi/userdata/scripts/snapshot1.png";
takeSnapshot(filepath);
takeSnapshot(filepath);