2021-12-19 18:26:08 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""Main asteroid-automator script."""
|
|
|
|
|
2021-12-19 18:02:58 +00:00
|
|
|
import os
|
|
|
|
|
2021-12-19 18:18:07 +00:00
|
|
|
import pyautogui
|
|
|
|
|
|
|
|
if os.name == "windows":
|
2021-12-19 18:02:58 +00:00
|
|
|
import d3dshot
|
|
|
|
|
2021-12-19 18:18:07 +00:00
|
|
|
|
2021-12-19 18:02:58 +00:00
|
|
|
class AutomatableGame:
|
2021-12-19 18:26:08 +00:00
|
|
|
"""Base class for each platform."""
|
|
|
|
|
2021-12-19 18:02:58 +00:00
|
|
|
def __init__(self):
|
|
|
|
self.loc = pyautogui.locateOnScreen("images/app.png")
|
2021-12-19 18:18:07 +00:00
|
|
|
|
2021-12-19 18:02:58 +00:00
|
|
|
def fetch_sshot(self):
|
2021-12-19 18:26:08 +00:00
|
|
|
"""Creates a screenshot, and returns it in Pillow format."""
|
2021-12-19 18:02:58 +00:00
|
|
|
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()
|
2021-12-19 18:18:07 +00:00
|
|
|
|
2021-12-19 18:02:58 +00:00
|
|
|
def fetch_sshot(self):
|
2021-12-19 18:26:08 +00:00
|
|
|
return self.d.screenshot() # TODO: Cut this to self.loc(x, y, w, h)
|