Python如何分割屏幕



我的有问题

这是图像

在不同的浏览器上有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://i.stack.imgur.com/WdBcU.jpg

最新更新