pywinauto print_control_identifiers()不起作用

时间:2018-10-08 23:53:10

标签: python windows user-interface automation pywinauto

有人知道我为什么看不到Adobe AIR安装程序完整树的原因

我的代码是:*由于未知原因,我无法启动应用程序并看到它,我需要先启动它,然后检查进程ID,然后使用“ connect(process = ID)” 或我有这个错误:

  

pywinauto.findwindows.ElementNotFoundError:{'best_match':   “ Adob​​eAIRSetup”,“后端”:“ uia”,“进程”:3480}

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

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

之后,我可以看到结果:

  

控制标识符:

     

ApolloRuntimeContentWindow-'Adobe AIR设置'(L1163,T107,R1883,   B754)['ApolloRuntimeContentWindow','Adobe AIR   SetupApolloRuntimeContentWindow”,“ Adob​​e AIR安装程序”]   child_window(title =“ Adob​​e AIR设置”,   class_name =“ ApolloRuntimeContentWindow”)

但是没有“我同意”和“取消”按钮,这就是为什么我不能单击它!

Adobe Setup Windows

Inspect I can see 2 buttons

enter image description here

1 个答案:

答案 0 :(得分:0)

使用“ import psutil”的解决方案将有助于获取PID并将其发送给connect方法!

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