1

现在我得到的是这个,但目前它在字符串实际存在之前截取屏幕截图,导致截屏太早了

        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() 它似乎会返回最后一张拍摄的图像,因为这一切都发生得如此之快

谢谢!

4

0 回答 0