Код работает но завершаться не хочет,как исправить + хотел добавить что при (нашел )изображения на экране код так же закрывался.
import itertools
import pyautogui
import keyboard
start_key = input("Введите клавишу запуска: ")
stop_key = input("Введите клавишу остановки: ")
keyboard.wait(start_key)
def cps1():
if keyboard.add_hotkey(start_key ,cps1):
while True:
pyautogui.press('E')
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1025, 1007)
pyautogui.sleep(0.25)
pyautogui.press('E')
pyautogui.press('E')
pyautogui.press('E')
pyautogui.press('E')
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1025, 1007)
pyautogui.sleep(0.25)
pyautogui.press('E')
pyautogui.press('E')
pyautogui.press('E')
pyautogui.press('E')
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1025, 1007)
pyautogui.sleep(0.25)
pyautogui.press('E')
pyautogui.press('E')
pyautogui.press('E')
pyautogui.press('E')
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1025, 1007)
pyautogui.sleep(0.25)
pyautogui.press('E')
pyautogui.press('E')
pyautogui.press('E')
pyautogui.press('E')
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1025, 1007)
pyautogui.sleep(0.25)
pyautogui.press('E')
pyautogui.press('E')
pyautogui.press('E')
pyautogui.press('E')
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1054, 946)
pyautogui.leftClick(1025, 1007)
pyautogui.sleep(0.25)
pyautogui.press('E')
pyautogui.press('E')
pyautogui.press('E')
pyautogui.press('E')
patch = "BUTTONS/ASD.png"
if pyautogui.locateOnScreen(patch, confidence = 0.8):
exit()
if keyboard.is_pressed(stop_key):
exit()
cps1()