-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtility.py
34 lines (29 loc) · 1.05 KB
/
Utility.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import cv2
from capture import WindowCapture
import pygetwindow
import time
import pyautogui
class Utility:
@classmethod
def template_matching(cls,image:str):
win = WindowCapture("Raid: Shadow Legends")
img = win.get_screenshot()
temp = cv2.imread(image)
res =cv2.matchTemplate(img, temp, cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
return max_val, max_loc
@classmethod
def resize_window(cls):
win = pygetwindow.getWindowsWithTitle("Raid: Shadow Legends")[0]
win.size = (1296, 759)
@classmethod
def reconnect(cls):
win = WindowCapture("Raid: Shadow Legends")
img = win.get_screenshot()
temp = cv2.imread("Template_Images/con_lost.png")
res =cv2.matchTemplate(img, temp, cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
if max_val > 0.9:
time.sleep(1)
pyautogui.click(win.get_screen_position((max_loc[0]+20,max_loc[1]+20)))
time.sleep(1)