如何在Mac(python)上检查屏幕上的特定颜色

2024-04-19 02:29:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我想做一个机器人的钢琴瓷砖在线mac上。我有按相关键的密码。我现在正在检查是否有一个灰色的瓷砖,我需要按。这是我目前的代码。(Python)

import time import pynput from pynput.keyboard import Key, Controller keyboard = Controller()

leftKey = True

if leftKey == True: keyboard.press('a') keyboard.release('a')

centerLeft = True

if centerLeft == True: keyboard.press('s') keyboard.release('s')

centerRight = True

if centerRight == True: keyboard.press('d') keyboard.release('d')

rightKey = True

if rightKey == True: keyboard.press('f') keyboard.release('f')

如果有人能让我知道如何检查是否有一个关键,我需要按下,然后按下它,这将是伟大的。谢谢。我在网上到处找答案,但都是针对Windows的。你知道吗


Tags: importtruereleaseif机器人关键press瓷砖