仅当出现两张图像时按

2024-09-28 05:27:10 发布

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

我正在使用PYautoGUI,我正在尝试制作一个脚本来解决一个难题。拼图告诉我点击这对(有两个的图片是什么) 到目前为止,我有以下代码:

    if pyautogui.locateCenterOnScreen('TapPair.png', confidence=0.9, region=(689, 250, 640, 1000)) != None:
    for image in images:
        found = list(pyautogui.locateAllOnScreen(image, confidence=0.99, region=(689, 250, 640, 1000)))
        if len(found) >= 2:
            for i in found:
                pyautogui.click(i)
                print("Got a match")
                time.sleep(2)
                break

问题是:它会点击与之匹配的每个图像。。。为什么?

编辑:下面是一个拼图enter image description here的示例


Tags: 代码inimage脚本forif图片region

热门问题