在屏幕Python上定位颜色位置

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

我想用pyautogui单击屏幕上的特定颜色,但是为此我需要它的位置,并且我找不到关于该主题的任何有用信息。我正在尝试使Piano Tiles自动点击器,为此,我考虑过确定瓷砖的颜色并单击它。

python python-imaging-library cv2 pyautogui
1个回答
0
投票

您可以用pyautogui找到颜色位置:

import pyautogui

color = (255, 255, 255)

s = pyautogui.screenshot()
for x in range(s.width):
    for y in range(s.height):
        if s.getpixel((x, y)) == color:
            pyautogui.click(x, y)  # do something here
© www.soinside.com 2019 - 2024. All rights reserved.