如何检查屏幕上的某些像素

问题描述 投票:0回答:0

我有这段代码,但无论我将图像更改为什么,它仍然不会点击字符。

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

我尝试更改它,以便它检查与上一帧的差异,但我也无法弄清楚。

python pyautogui
© www.soinside.com 2019 - 2024. All rights reserved.