import pyautogui
import keyboard
print("Запуск F5 ")
print("Остановка F4 ")
start_key = ('F5')
stop_key =('F4')
keyboard.wait(start_key)
def cps1():
if keyboard.add_hotkey(start_key, cps1):
while True:
if keyboard.is_pressed(stop_key):
break
if pyautogui.locateOnScreen("C:/Users/Octava/Documents/Program/BUTTONS/ASD.png", confidence=0.7):
break
pyautogui.press('E')
pyautogui.sleep(0.27)
pyautogui.doubleClick(1054, 946)
pyautogui.doubleClick(1054, 946)
pyautogui.leftClick(1025, 1007)
pyautogui.leftClick(1025, 1007)
cps1()