不能用AutoI监视CheckListBox

2024-10-05 10:55:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我不能用AutoIt监视窗口框中的CheckListBox对象(我认为是Delphi)。它在这片区域什么也看不见。我需要从该地区获得项目列表,并可能选择其中一个项目。在

我使用的是python和robotframework。在

我还尝试使用ControlListView:

self.get_autoit().ControlListView("Setup - XXXXX", "Select the XXXX", "[CLASS:TNewCheckListBox; INSTANCE:1]", "GetText")

但它引发了:

^{pr2}$

这个错误似乎是pywinauto的问题。在

无论如何,我不能从这个讨厌的对象得到项目列表。在

autoit spy的结果显示在屏幕截图中:

result from autoit spy

有谁能建议一个好的方法来访问这个不明区域的物品清单吗?在

我能看到里面的东西检查.exe公司名称:

from inspect.exe


Tags: 项目对象self区域列表getsetup地区
1条回答
网友
1楼 · 发布于 2024-10-05 10:55:30

请在评论中看到瓦西里的详细回答。但是总结一下:

在最初的问题中,我试图使用pyautoit从CheckListBox中获取项目列表,但是因为它不起作用。因此,正如Vasily建议的那样,我在UIA模式下使用了pywinauto(另一种自动化工具),以下是对我有用的:

self.Wizard = Application(backend="uia").connect(title = self.installerTitle) #connect the application
self.Wizard.InstallerDialog.TreeView.wait('visible', timeout=150) #wait for tree view to load
        items = self.Wizard.InstallerDialog.TreeView.children() #get the children of tree view
        for item in items:  #iterate through items, radio button in this case
            if item.window_text() == "item_name_to_select":
                item.click_input() #click radio button if the text is what we are looking for
                return
        print "no item found with name: item_name_to_select"

最有用的技巧是在pywinauto中使用print_control_identifiers()方法来获取控件的标识符。另外,uia模式中的inspect.exe有助于识别对象。在

相关问题 更多 >

    热门问题