请问,怎么使用python的auto来识别到添加到通讯录的按钮啊?
现在代码可以到点击搜索出现这个框框,但是没办法识别的这个子框
# 定义处理添加到通讯录的函数
def handle_add_to_contacts(win):
try:
# 查找“添加到通讯录”按钮
add_to_contacts_buttons = win.children(title="添加到通讯录", control_type="Button")
if add_to_contacts_buttons:
for i, button in enumerate(add_to_contacts_buttons):
button.draw_outline(colour='green', thickness=2) # 描边标识按钮
print(f"描边标识了第 {i+1} 个添加到通讯录按钮")
add_to_contacts_buttons[0].wait('visible', timeout=10) # 等待按钮可见
add_to_contacts_buttons[0].click_input() # 选择第一个匹配的按钮
print("已点击添加到通讯录按钮")
else:
print("未找到添加到通讯录按钮")
except Exception as e:
print(f"处理添加到通讯录时出错: {e}")
##############33###################33###########333333
search_result_item = search_result_list.child_window(title="搜索:" + wechat_id, control_type="ListItem")
if search_result_item.exists():
search_result_item.click_input()
print(f"已查询到微信号: {wechat_id}")
# 检查是否需要添加到通讯录
handle_add_to_contacts(win)
else:
print(f"未找到微信号: {wechat_id}")