现在我得到的是这个,但目前在字符串实际存在之前需要屏幕截图导致屏幕截图过早拍摄
if(string_75_.contains("You have defeated ")) {
takeScreenshot(true);
}
这是我的整个版画程序
static boolean takeScreenshot(boolean verbose){
try{
File file = getEmptyFile();
Wait(50);
ImageIO.write(getImage(), "png", file);
if (verbose) {
System.out.println("Screenshot saved as " + file.getName() + ".");
}
return true;
}
catch (IOException e) {
if (verbose)
System.out.print("Error saving screenshot.");
}
return false;
}
private static BufferedImage getImage() throws IOException {
try {
Robot robot = new Robot();
Wait(120);
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_PRINTSCREEN);
robot.keyRelease(KeyEvent.VK_PRINTSCREEN);
robot.keyRelease(KeyEvent.VK_ALT);
BufferedImage bufferedImage = (BufferedImage)getClipboard();
return bufferedImage;
} catch (AWTException e) {
BufferedImage bufferedImage = new BufferedImage(765,503 + 11, 1);
return bufferedImage;
}
}
现在主要的问题是等待导致我的应用程序停止了整个但是STILL无法提前截取屏幕截图...任何帮助都是感谢
还有办法清除剪贴板吗?没有我的等待()它似乎返回最后拍摄的图像,因为它发生的一切都很快
谢谢!