微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么我的代码中的搜索图像不起作用?

如何解决为什么我的代码中的搜索图像不起作用?

这是我的代码

 import pyautogui


images = ['colordonkergrijsDCphrasev2.png'] #the image I want it to find
while True:
  for image in images: #search for the image in images
    pos = pyautogui.locateOnScreen(image,region=(740,870,50,20)) #search on the screen for the image
    if pos is not None: # this checks that the image was found   
      pyautogui.click(pos) # click the position of the image 

我希望我的代码在他看到该图像时点击一个特殊区域。 但是我的代码没有这样做,当图像不存在时,我的代码每次都会点击。我使用的图像与背景非常相似。但是我加了 confidence = 1 还是不行 有人知道如何解决吗? 我使用 Python 3.9.4 64 位。 我已经阅读了文档,但没有任何内容可以帮助我。 如果你想在这里文档是:https://pyautogui.readthedocs.io/en/latest/screenshot.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。