pyautogui.locateOnScreen() for multiple images?

心不动则不痛 提交于 2021-01-28 07:09:38

问题


How would you do pyautogui.locateOnScreen() for multiple images a bunch of images?


回答1:


Try this out:

import os
import pyautogui as py


image_list = []

# Get list of all files in current directory
directory = os.listdir()

# Find files that end with .png or .jpg and add to image_list
for file in directory:
    if file.endswith('.png') or file.endswith('.jpg'):
        image_list.append(file)

# Loop through list to find all the images
for image in image_list:
    print(image)
    print(py.locateOnScreen(image))

This question is similar to another one, I posted the same answer in both places.



来源:https://stackoverflow.com/questions/65044841/pyautogui-locateonscreen-for-multiple-images

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!