0

I have this code but no matter what I change the image to it still won't click on the characters.

import time
import pyautogui
import keyboard

program_running = True

# Get the size of the screen
screen_width, screen_height = pyautogui.size()

# Calculate the center of the screen
center_x = screen_width / 2
center_y = screen_height / 2


def switch_tab():
    pyautogui.keyDown("alt")
    pyautogui.press("tab")
    pyautogui.keyUp("tab")
    pyautogui.keyUp("alt")


switch_tab()
time.sleep(0.1)

while program_running:
    man_found = pyautogui.locateOnScreen("Images\\Storm_The_House\\man_1.png")

    if man_found:
        pyautogui.click(man_found)
    elif not man_found:
        print("no")

    if keyboard.is_pressed("esc"):
        program_running = False
        break

I tried changing it so it checks for differences from the last frame instead but I couldn't figure that out either.

L_Void_X
  • 1
  • 1
  • Does this answer your question? [Why PyAutoGui LocateOnScreen() only Returns None](https://stackoverflow.com/questions/43702511/why-pyautogui-locateonscreen-only-returns-none) – Dan Getz Mar 14 '23 at 12:23
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Community Mar 14 '23 at 14:03

0 Answers0