Browse Source

error bugfix

Neccor 4 years ago
parent
commit
7026b8516e
2 changed files with 5 additions and 12 deletions
  1. 1
    1
      .gitignore
  2. 4
    11
      main.py

+ 1
- 1
.gitignore View File

2
 # Custom
2
 # Custom
3
 screenshots/
3
 screenshots/
4
 screenshot.png
4
 screenshot.png
5
-error/*
5
+error/*.*
6
 
6
 
7
 # Byte-compiled / optimized / DLL files
7
 # Byte-compiled / optimized / DLL files
8
 __pycache__/
8
 __pycache__/

+ 4
- 11
main.py View File

2
 import time
2
 import time
3
 import pyautogui
3
 import pyautogui
4
 from datetime import datetime, date
4
 from datetime import datetime, date
5
-from os.path import isfile, join
6
-import os
7
 
5
 
8
 eol = int(0)
6
 eol = int(0)
9
 
7
 
10
-if not os.path.exists(os.path.join(os.getcwd(), "error")):
11
-	os.path.join(os.getcwd(), "error")
12
-
13
 def find(image, coef=None):
8
 def find(image, coef=None):
14
 	template = cv2.imread("assets/{}".format(image), 0)
9
 	template = cv2.imread("assets/{}".format(image), 0)
15
 	width, height = template.shape[::-1]
10
 	width, height = template.shape[::-1]
16
 	screen = cv2.imread("screenshot.png", 0)
11
 	screen = cv2.imread("screenshot.png", 0)
17
 	width2, height2 = screen.shape[::-1]
12
 	width2, height2 = screen.shape[::-1]
18
-	# print(f"Breite: {width} | Höhe: {height}\nBreite: {width2} | Höhe: {height2}")
19
 	match = cv2.matchTemplate(screen, template, cv2.TM_CCOEFF_NORMED)
13
 	match = cv2.matchTemplate(screen, template, cv2.TM_CCOEFF_NORMED)
20
 	value, location = cv2.minMaxLoc(match)[1], cv2.minMaxLoc(match)[3]
14
 	value, location = cv2.minMaxLoc(match)[1], cv2.minMaxLoc(match)[3]
21
-	print(f"{image} | {value}")
22
 	if (value >= 0.85):
15
 	if (value >= 0.85):
23
-		print(f"{image} | {value}")
24
 		return (location[0], location[1], width, height, value)
16
 		return (location[0], location[1], width, height, value)
25
 	else:
17
 	else:
26
 		return None
18
 		return None
28
 def autoduelloop(eol):
20
 def autoduelloop(eol):
29
 	while True:
21
 	while True:
30
 		time.sleep(1)
22
 		time.sleep(1)
31
-		print(f"\n")
32
 		pyautogui.screenshot("screenshot.png")
23
 		pyautogui.screenshot("screenshot.png")
33
 
24
 
34
 		# OK Button
25
 		# OK Button
111
 
102
 
112
 		# End of the Loop
103
 		# End of the Loop
113
 		print(f"End of the Loop | EOL: {eol}")
104
 		print(f"End of the Loop | EOL: {eol}")
114
-		time.sleep(0)
105
+		time.sleep(3)
115
 		if eol >= 5:
106
 		if eol >= 5:
116
 			# Arrow
107
 			# Arrow
117
 			arrow = find("arrow.png")
108
 			arrow = find("arrow.png")
123
 while True:
114
 while True:
124
 	autoduelloop(eol)
115
 	autoduelloop(eol)
125
 	eol += 1
116
 	eol += 1
126
-	if eol >= 10:
117
+	if eol == 10:
118
+		pyautogui.click((950, 280))
119
+	elif eol >= 15:
127
 		time.sleep(1)
120
 		time.sleep(1)
128
 		eol = int(0)
121
 		eol = int(0)
129
 		pyautogui.screenshot(f"error/error-{datetime.now().strftime('%Y-%m-%d-%H-%M')}.png")
122
 		pyautogui.screenshot(f"error/error-{datetime.now().strftime('%Y-%m-%d-%H-%M')}.png")

Loading…
Cancel
Save