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

32 lines
811 B
Python
Raw Normal View History

2023-09-24 01:27:02 +02:00
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__":
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.8
locations = where(result >= threshold)
# Fetch coordinates
locations = list(zip(*locations[::-1]))[0]
# Move and click
moveTo(locations[0], locations[1])
click()
# Wait a second every loop
sleep(1)