1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] PywinAuto API - child_window - returning multiple elements

Discussão em 'Python' iniciado por Stack, Novembro 24, 2025.

  1. Stack

    Stack Membro Participativo

    Here is my code which is throwing me an error I am trying to open a Group Policy Editor and select setting under Personalization.

    I have obtained the sample code from this question

    GUI Automation of policy change for logoff button. pywinauto.findwindows.ElementNotFoundError: error. How to switch context?

    import pywinauto

    pywinauto.Application().start(r'mmc gpedit.msc')
    app = pywinauto.Application(backend="uia").connect(path='mmc.exe')

    main_window = app.top_window()
    main_window.maximize()

    admin_template = app.LocalGroupPolicyEditor.child_window(title="User Configuration", control_type="TreeItem").child_window(title="Administrative Templates", control_type="TreeItem")
    admin_template.double_click_input()


    I get the error saying -

    There are 50 elements that match the criteria {'title': 'User Configuration', 'control_type': 'TreeItem', 'top_level_only': False, 'parent': <uia_element_info.UIAElementInfo - 'Local Group Policy Editor', MMCMainFrame, 4330080>, 'backend': 'uia'}


    How do I workaround this error - every query on the internet shares similar code - but it does not work

    How do I select an entry under Personalization - TreeViewItem. I need to select the DataItem on the right side ex - a setting under Personalization -

    "Prevent lock screen background motion"

    and access its values

    Continue reading...

Compartilhe esta Página