在屏幕 Python 上定位颜色位置 [英] Locate color position on screen Python
本文介绍了在屏幕 Python 上定位颜色位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用 pyautogui 单击屏幕上的特定颜色,但为此我需要它的位置,但我找不到有关该主题的任何有用信息.我正在尝试制作一个 Piano Tiles 自动点击器,为此我考虑过识别瓷砖的颜色并点击它.
I want to click on a specifical color on the screen with pyautogui, but for that I need its position, and I can't find any useful information about the topic. I'm trying to make a Piano Tiles autoclicker and for that I've thought about identifying the tiles' color and clicking it.
推荐答案
您可以使用 pyautogui
找到颜色位置:
You can find color position with 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
这篇关于在屏幕 Python 上定位颜色位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文