There are multiple ways to do that. The code for these will require modification based on your needs, so I will put in some pointers to the high level methods and libraries:
-
You can directly use GUI-automation tools such as
Pyautogui
to pressAlt
+PrntScreen
and transfer the data from clipboard into a variable (http://pyautogui.readthedocs.io/en/latest/keyboard.html#keyboard-keys) -
You can use pywin32 and PIL to grab the image of a certain window (How to Get a Window or Fullscreen Screenshot in Python 3k? (without PIL))
-
You can use imagemagik to grab screenshots of a single window (https://www.imagemagick.org/discourse-server/viewtopic.php?t=24702)
-
You can use
Pyautogui.locateOnScreen(“Sceenshot.PNG”) to find the tuple which will contain the boundaries of the window for your java app. Then you can pass it to your function
img.ImageGrab.grab(bbox)`