Python如何分屏

Python how to split the screen

我有问题

Here's the image

在不同的浏览器上有3张相同的图片。我想分别处理每一个。我该如何拆分它们?

我是 python 的初学者,我是新手,我尝试过这样的事情:

while 1:
if pyautogui.locateOnScreen(IMG_1):
    click(101, 488)
    sleep(1)
    print("clicking")
    if pyautogui.locateOnScreen(IMG_2): ## After than img_1, img_2 comes the screen
        click(205, 689)
        sleep(1)
        print("img_2 done")

这仅适用于 1 个浏览器。

我在尝试了解是否要拆分图像并将每个图像放在不同的浏览器中时感到困惑。之后,我写了这个:

import pyautogui
from time import sleep

img_1 = "1st.png"
img_2 = "2nd.png"
img_3 = "3th.png"

def click(pos):
    pyautogui.moveTo(pos)
    sleep(.5)
    pyautogui.click()

while True:
    try:
        pos_img_1 = pyautogui.locateOnScreen(img_1)
        pos_img_2 = pyautogui.locateOnScreen(img_2)
        pos_img_3 = pyautogui.locateOnScreen(img_3)

        if pos_img_1 != None:
            sleep(.5)
            click(img_1)
            print("Clicking...")

        if pos_img_2 != None:
            sleep(.5)
            click(img_2)
            print("Clicking...")
        
        if pos_img_3 != None:
            sleep(.5)
            click(img_3)
            print("Clicking...")
          
    except Exception as error:
        print(error)

这是拆分图像 > https://imgur.com/a/Onz2CjT