java打印筛选
现在我得到的是这个,但是现在它在字符串实际存在之前截图,导致截图被截图得太早java打印筛选,java,image,awt,screenshot,awtrobot,Java,Image,Awt,Screenshot,Awtrobot,现在我得到的是这个,但是现在它在字符串实际存在之前截图,导致截图被截图得太早 if(string_75_.contains("You have defeated ")) { takeScreenshot(true); } 这是我的整个打印屏幕程序 static boolean takeScreenshot(boolean verbose){ try{ File file = getEmptyFile();
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;
}
}
现在的主要问题是,等待导致我的应用程序完全停止,但仍然无法提前截图。。。任何帮助都是感谢的
还有没有办法清除剪贴板?如果没有我的等待()它似乎会返回上次拍摄的图像,因为这一切发生得太快了
谢谢 问题最有可能出现在
Wait(int)
方法中(该方法应称为Wait(int)
)。为了更快地获得更好的帮助,请发布一个.See。我还必须重新创建wait()方法,使其成为静态的,这样它才是可用的。我所有的方法都必须是静态的,才能与我正在使用的方法兼容。这听起来好像设计完全一团糟。但是当我看到一个SSCCE的时候,会有更多的评论。我刚刚注意到Class245.method2261
Wow!你能不能给我们说清楚?