From 3f9af5012cba5c155305720eae058b4fe727ac8c Mon Sep 17 00:00:00 2001 From: John McCardle Date: Sun, 19 Dec 2021 13:02:58 -0500 Subject: [PATCH] Cross-platform basics on capturing the game screen to a PIL image. --- main.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..ba9eccf --- /dev/null +++ b/main.py @@ -0,0 +1,24 @@ +import pyautogui +import os + +if os.name == 'windows': + import d3dshot + +class AutomatableGame: + def __init__(self): + self.loc = pyautogui.locateOnScreen("images/app.png") + + def fetch_sshot(self): + return pyautogui.screenshot(region=self.loc) + + def send_key(self, key): + pass + + +class AutomatableGame__Windows(AutomatableGame): + def __init__(self): + super().__init__(self) + self.d = d3dshot.create() + + def fetch_sshot(self): + return d.screenshot() # Cut this to self.loc(x, y, w, h)