Search code examples
pythonpywinauto

pywinauto access a nested submenue


In pywinauto I am trying to access a nested submenue item that contains. The Path is Datei->Importieren->Vorlagen->comdirect Musterdepot (attached screenshot)

Any idea how I can get this running?

The code I use:

app = Application(backend = 'uia').connect(path = "PortfolioPerformance.exe")
app.Dialog.Anwendungsmenü.item_by_path('Datei->Importieren->Vorlagen->comdirect Musterdepot').click_input()

The error I receive:

AttributeError: 'NoneType' object has no attribute 'is_active'

Screenshot of Menu: Path of the Submenu


Solution

  • After spending some time I figured out the following behaviour: Once I expanded the Datei Menu, the print_control_identifiers updated to include the submenues. The following code will click the correct, but maybe there are nicer solutions out there:

    app = Application(backend = 'uia').connect(path = PROCNAME)
    dialog = app.dialog
    #first open the Importieren submenu:
    dialog.Anwendungsmenü.item_by_path('Datei->Importieren') 
    # then the submenue appears on top level menues, open the importieren menu:
    dialog["Importieren"].item_by_path('Vorlagen->comdirect Musterdepot').select()