简体   繁体   English

pywinauto 功能区菜单不返回控件标识符

[英]pywinauto ribbon menu returns no control identifiers

I'm trying to automate a series of tasks I have to do with a given software.我正在尝试自动化一系列与给定软件有关的任务。 I've managed to "wing it" using keyboard controls, but to extend the complexity of the script I need to access a ribbon menu.我已经设法使用键盘控件“控制它”,但是为了扩展脚本的复杂性,我需要访问功能区菜单。

So far, my code is as follows:到目前为止,我的代码如下:

windows = pwa.Desktop(backend="win32").windows()
running_windows = [window.window_text() for window in windows]

midas_title = ""
target_title = "Civil"

for window in running_windows:
    if target_title in window:
        midas_title += window
    else:
        pass

app = pwa.Application().connect(title=midas_title)
app[midas_title].set_focus()

app.MidasGenMainFrmClass['MIDAS/Civil'].print_control_identifiers()
app.MidasGenMainFrmClass['BCGPRibbonBar:40000000:8:10003:10'].print_control_identifiers()

Judging by the top/left and bottom/right coordinates of the BCGPRibbonBar:40000000:8:10003:10 , that seems to be the menu that I want to access so that I can click on the "Results" button in this ribbon (my final goal), but when I do print_control_identifiers() on that the output I get is this:根据BCGPRibbonBar:40000000:8:10003:10的上/左和下/右坐标判断,这似乎是我想要访问的菜单,以便我可以单击此功能区中的“结果”按钮(我的最终目标),但是当我执行print_control_identifiers()时,我得到的输出是这样的:

BCGPRibbonBar:40000000:8:10003:10 - 'MIDAS/Civil'    (L0, T0, R1920, B174)
['MIDAS/CivilBCGPRibbonBar:40000000:8:10003:10', 'BCGPRibbonBar:40000000:8:10003:10', 'MIDAS/Civil']
child_window(title="MIDAS/Civil", class_name="BCGPRibbonBar:40000000:8:10003:10")

I'm very new to this, but seems like the ribbon has no children?我对此很陌生,但似乎功能区没有孩子?

Seems like I'm too new to embed images, but link here to what the ribbon menu looks like似乎我太新,无法嵌入图像,但请在此处链接到功能区菜单的外观

And finally, link to the image of the inspector of the "Results" menu where I'd like to click最后,链接到我想点击的“结果”菜单的检查员图像

Hopefully this is sufficient information, but please let me know if anything is missing.希望这是足够的信息,但如果有任何遗漏,请告诉我。

If anyone has any idea of what I might be doing wrong, that would be extremely helpful.如果有人知道我可能做错了什么,那将非常有帮助。

Use backend="uia" instead of backend="win32" .使用backend="uia"而不是backend="win32" Ribbon controls are visible to UIA backend only.功能区控件仅对 UIA 后端可见。 Application(backend="uia") is also a must. Application(backend="uia")也是必须的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM