I've been trying to make a simple script, it presses the key when the image of the key is visible in the left bottom corner of the screen. The problem is when I'm in the game (Multi Theft Auto) the script stops working only in the game window. I tried running script/game as administrator, changing resolution, making the game windowed/fullscreen but nothing changes. Here's my code: from numpy import random import pyautogui import pydirectinput import time import keyboard import random import win32api, win32con sleeptime1 = random.uniform(1.05, 2.03) sleeptime2 = random.uniform(1.04, 2.01) sleeptime3 = random.uniform(1.02, 2.05) while True: if pyautogui.locateCenterOnScreen('key_a.png', region=(0,580,500,500), grayscale=True, confidence=0.7) != None: pydirectinput.press('e') time.sleep(sleeptime1) if pyautogui.locateCenterOnScreen('key_b.png', region=(0,580,500,500), grayscale=True, confidence=0.7) != None: pydirectinput.press('q') time.sleep(sleeptime2) else: pydirectinput.click() time.sleep(sleeptime3) Continue reading...