Python-声明图像点击的特定区域

标签 python pyautogui

我是 Python 新手! 我想定义一个小区域来读取图像,而不是搜索整个屏幕。我有下面的一些代码,但没有成功:

import pyautogui, time
while True:    
    if pyautogui.screenshot(region=(666,0, 200, 200)pyautogui.locateOnScreen(r'C:\Users\Lawrence\Desktop\PyTest\image.png', grayscale=True)):
       pyautogui.click(1880,15)
       time.sleep(0.1)
       break

希望有人能帮忙!非常感谢!

最佳答案

也许是这样的?

import pyautogui, time

while True:
    if pyautogui.locateOnScreen(image=r'C:\Users\Lawrence\Desktop\PyTest\image.png', region=(666,0, 200, 200), grayscale=True):
        pyautogui.click(1880,15)
        time.sleep(0.1)
        break

关于Python-声明图像点击的特定区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48706721/

相关文章:

python - 删除列表中所有长度为 x 的字符串

python - 如何识别图像并点击它们

python - 如何在网速慢时停止pyautogui并恢复之前的程序代码

javascript - 添加 Bokeh curdoc 的自定义脚本

python - 如何接收 Python 中发生的命令输出?

python - 如何使用Python CV2套件测量圆心角

python - Pyautogui 在导入时更改窗口大小

python - 使用区域加速 pyautogui screenshot()

python - 我现在正在使用 pyautogui 模块,来自使用 Python 自动化无聊的东西。我的代码一直告诉我 pyscreeze 没有属性 locateOnWindow

python - QT4、GTK+、wxWidgets 或 IronPython,用于使用 Python 的 native Windows 应用程序