Search code examples
pythonwindowsuser-interfaceautomationpywinauto

pywinauto print_control_identifiers() doesn't work


Does anybody know the reason why I can't see full tree for Adobe AIR Setup Installer

My code is: * for unknown reason I can not start app and see it, I need first start it, then check process ID, and after use "connect(process=ID)" or I have this error:

pywinauto.findwindows.ElementNotFoundError: {'best_match': 'AdobeAIRSetup', 'backend': 'uia', 'process': 3480}

#app = Application(backend='uia').start(r'AdobeAIRInstaller.exe')

app = Application().connect(process=9880) 
app.AdobeAIRSetup.print_control_identifiers()

After that I can see result:

Control Identifiers:

ApolloRuntimeContentWindow - 'Adobe AIR Setup' (L1163, T107, R1883, B754) ['ApolloRuntimeContentWindow', 'Adobe AIR SetupApolloRuntimeContentWindow', 'Adobe AIR Setup'] child_window(title="Adobe AIR Setup", class_name="ApolloRuntimeContentWindow")

But there are no "I Agree" and "Cancel" button, that is why I can not click on it !

Adobe Setup Windows

Inspect I can see 2 buttons

enter image description here


Solution

  • The solution with "import psutil" will help to obtain PID and send it to connect method!

    from pywinauto import Application, Desktop
    
    import psutil
    
    
    PROCNAME = "Adobe AIR Installer.exe"
    app = Application(backend='uia').start(r'AdobeAIRInstaller.exe')
    apploaded = False
    
    
    while apploaded == False:
        for proc in psutil.process_iter():
            if proc.name() == PROCNAME:
                print(proc.pid)
                app = Application(backend='uia').connect(process=proc.pid)
                apploaded = True