py-autogui/main.py

34 lines
878 B
Python
Raw Permalink Normal View History

2023-09-14 02:40:30 +08:00
from PIL import Image
from mss import *
from pyautogui import *
import utils.cv2
FAILSAFE = False
screen_size = size()
screen_x, screen_y = screen_size.width, screen_size.height
if __name__ == '__main__':
if not os.path.exists("snap"):
os.mkdir("snap")
with mss() as m:
monitors = m.monitors[:1]
for (i, monitor) in enumerate(monitors):
print(monitor)
img = m.grab(monitor)
pim = Image.new("RGB", img.size)
pim.frombytes(img.rgb)
# loc = utils.cv2.match(pim, "assets/images/win_win10.png")
# if loc is not None:
# x, y = loc
# moveTo(x, y)
2023-09-17 16:37:43 +08:00
loc = utils.cv2.match_resize(pim, "assets/images/test.png", 0.8)
2023-09-14 02:40:30 +08:00
if loc is not None:
x, y = loc
moveTo(x, y)
print(screen_x, screen_y)