需要是WindowSpecification.print_control_identifiers()
里能看到的元素才能这么去操作。如果看不到的话,可能是因为对Windows系统给开放的权限不够,如果还是想进行自动化操作的话可以用pyautogui包来模拟人工操作。
子窗口下拉列表:
combo_box = main_window.child_window(auto_id, control_type="ComboBox")
点击下拉列表的“打开”按钮和点击按钮:
open_button = combo_box.child_window(
title="打开", auto_id="DropDown", control_type="Button"
)
open_button.click()
选择第一项:
list_box = combo_box.child_window(title="请在列表中选择奖品:", control_type="List")
items = list_box.items()
if items:
first_item = items[
0
]
first_item.select()
else:
print("没有可选项")