time.sleep(2)
screenshot = capture_screen_at_mouse()
screenshot_gray = cv2.cvtColor(np.array(screenshot), cv2.COLOR_RGB2GRAY)
screenshot_window = tk.Toplevel(root)
screenshot_window.title("Screenshot")
for file_name in os.listdir(folder_path):
if file_name in target_images:
template_path = os.path.join(folder_path, file_name)
template = cv2.imread(template_path, cv2.IMREAD_GRAYSCALE)
if template.shape[0] > screenshot_gray.shape[0] or template.shape[1] > screenshot_gray.shape[1]:
template = cv2.resize(template, (screenshot_gray.shape[1], screenshot_gray.shape[0]))
result = cv2.matchTemplate(screenshot_gray, template, cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
if max_val > 0.8:
print(f"Ähnlichkeit gefunden mit {file_name} bei {max_loc}")
break
img = ImageTk.PhotoImage(screenshot)
label = tk.Label(screenshot_window, image=img)
label.image = img
label.pack()
def show_Game():
start_button = tk.Button(root, text="Start Game", bg="blue", fg="white", command=show_screenshot)
start_button.place(x=5, y=50)```