使用来自检查工具的数据进行pywinauto

问题描述 投票:1回答:1

我正在努力自动化一个名为MEmu Instance Manager的应用程序。

对于我的项目,我想返回存在的实例数量,以及使用pywinauto模块和windows工具包中的检查工具命名的实例。

基于Inspect工具,MEmu应用程序的结构如下

MainWindow
    Parent
        Child1
        InstanceArea
            TARGET
            WIDGETS

使用检查工具检查目标小部件时,这就是我得到的。

enter image description here

我想要返回的字符串是“b__”

你如何使用python返回Legacy|Accessible.Value字符串?在执行此操作之前是否需要指定窗口小部件的路径?

如果是这样,怎么样?我已经在pywinauto指南上阅读了很多有用的信息,但是我在MEmu中使用我从检查中得到的信息时遇到了麻烦。

例如,

enter image description here

有了上面的信息,我不能用提供的信息参考这个窗口。

我是一名初学者,我已经在这方面工作了几天,并且无处可去。 PLZ帮助*哭了一声

python-3.x ui-automation pywinauto inspect
1个回答
1
投票

可能这种方式应该有效:

from pywinauto import Application

app = Application(backend="uia").connect(title='MainWindow')
# app.MainWindow.dump_tree() # useful to get child_window spec for just a copy-paste!

target = app.MainWindow.child_window(title='TARGET', control_type='Edit').wrapper_object()
# maybe try control_type='Text' depending on info from Inspect.exe

# when you found the control, just get the text
target.legacy_properties()['Value'] # .legacy_properties() returns a dict

我没有用真正的应用实例检查它。希望你能在边缘调整它。

© www.soinside.com 2019 - 2024. All rights reserved.