This repository has been archived on 2023-09-24. You can view files and clone it, but cannot push or open issues or pull requests.
gbc/main.py
2023-09-24 01:32:37 +02:00

36 lines
1 KiB
Python

from time import sleep
from cv2 import TM_CCOEFF_NORMED, imread, matchTemplate
from numpy import where
from PIL import ImageGrab
from pyautogui import click, moveTo
if __name__ == "__main__":
print("Running...")
while True:
# Screenshot
screenshot = ImageGrab.grab()
screenshot.save("temp.png")
# Load images
main_image = imread("temp.png")
template_image = imread("goldburger.png")
# Find the burger
result = matchTemplate(main_image, template_image, TM_CCOEFF_NORMED)
threshold = 0.6
locations = where(result >= threshold)
# Fetch coordinates
locations = list(zip(*locations[::-1]))
# If we find a burger
if len(locations):
coordinates = locations[0]
print(f"Find a golden burger at {coordinates[0]}x{coordinates[1]}")
# Move and click
moveTo(coordinates[0], coordinates[1])
click()
# Wait a second every loop
sleep(1)