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

Python-declare specific region for image clicking

我是 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