简体   繁体   中英

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 - '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" . Ribbon controls are visible to UIA backend only. Application(backend="uia") is also a must.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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