以下是一个按键精灵软件区域找图脚本的示例,用于在指定区域内随机寻找带有锁符号的图片,并点击对应区域的不带符号的图片:

# 导入按键精灵库
import pyautogui

# 定义区域坐标
left = 1088
top = 301
right = 1397
bottom = 523

# 定义要查找的图片路径
locked_image_path = 'locked.png'  # 带有锁符号的图片路径
unlock_image_path = 'unlock.png'  # 不带符号的图片路径

# 设置查找图片的相似度阈值(可根据实际情况调整,默认为0.8)
confidence_threshold = 0.8

def click_unlocked_image():
    # 在指定区域内查找带有锁符号的图片
    locked_image_location = pyautogui.locateCenterOnScreen(locked_image_path, region=(left, top, right-left, bottom-top), confidence=confidence_threshold)
    
    # 如果找到锁符号图片,则点击对应区域的不带符号的图片
    if locked_image_location is not None:
        unlock_image_location = pyautogui.locateCenterOnScreen(unlock_image_path, region=(left, top, right-left, bottom-top), confidence=confidence_threshold)
        if unlock_image_location is not None:
            x, y = unlock_image_location
            pyautogui.click(x, y)
        else:
            print('未找到不带符号的图片')
    else:
        print('未找到带有锁符号的图片')

# 调用函数执行点击操作
click_unlocked_image()

请将示例中的'locked.png'和'unlock.png'替换为实际使用的图片路径,确保图片与实际界面一致。同时,你还可以根据实际情况调整区域坐标和相似度阈值,以满足你的需求。请确保已安装好按键精灵软件和相应的Python库,并按照软件的使用说明来运行脚本。

按键精灵区域找图脚本:随机寻找带锁图片并点击无锁图片

原文地址: https://www.cveoy.top/t/topic/bX0h 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录