我正在使用 Pywinauto GUI 自动化并面临 Adobe Acrobat 菜单或其子菜单上控件的错误
I am using Pywinauto GUI automation & facing errors with controls on the Adobe Acrobat menus or its submenus
下面是代码片段和错误消息。
任何帮助将不胜感激。
pdf_file = "C:\Users\Test1.PDF"
from pywinauto.application import Application
app = Application(backend='uia').start(cmd_line=u"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe " +pdf_file)
appw = app.connect(title="Adobe Acrobat Reader DC").window(class_name='AcrobatSDIWindow')
app_menu = appw.child_window(title="Application", control_type="MenuBar")
app_menu.child_window(title="File").expand()
file1 = appw.child_window(title="File", control_type="Menu")
file1.child_window(title="Print...").click_input()
错误信息:
raise ElementNotFoundError(kwargs)
pywinauto.findwindows.ElementNotFoundError: {'title': 'Adobe Acrobat Reader DC', 'backend': 'uia', 'visible_only': False}
Process finished with exit code 1
试试下面的代码
'''
import time
from pywinauto.application import Application
pdf_file = r"C:\Users\Test1.PDF"
acrobat_path = r"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
wpfApp = Application(backend=u'uia').start(cmd_line = acrobat_path + ' ' + pdf_file)
time.sleep(1)
wpfApp = Application(backend=u'uia').connect(path=acrobat_path) # Reconnect
wind = wpfApp.windows()
title = wind[0].get_properties()[u'texts'][0] # retrive Title of window
app_wind = wpfApp.window(title = title) #get access tp main window
app_menu = app_wind.children(title="Application", control_type="MenuBar") #get access to app menu
app_menu[0].children(title="File")[0].click_input() #click on File Menu
file_menu = app_wind.children(title="File", control_type="Menu") #get access to file menu window
file_menu[0].children(title="Print... Ctrl+P")[0].click_input() #click on Print
time.sleep(5) #wait for print dialog to open
'''
下面是代码片段和错误消息。 任何帮助将不胜感激。
pdf_file = "C:\Users\Test1.PDF"
from pywinauto.application import Application
app = Application(backend='uia').start(cmd_line=u"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe " +pdf_file)
appw = app.connect(title="Adobe Acrobat Reader DC").window(class_name='AcrobatSDIWindow')
app_menu = appw.child_window(title="Application", control_type="MenuBar")
app_menu.child_window(title="File").expand()
file1 = appw.child_window(title="File", control_type="Menu")
file1.child_window(title="Print...").click_input()
错误信息:
raise ElementNotFoundError(kwargs)
pywinauto.findwindows.ElementNotFoundError: {'title': 'Adobe Acrobat Reader DC', 'backend': 'uia', 'visible_only': False}
Process finished with exit code 1
试试下面的代码
'''
import time
from pywinauto.application import Application
pdf_file = r"C:\Users\Test1.PDF"
acrobat_path = r"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
wpfApp = Application(backend=u'uia').start(cmd_line = acrobat_path + ' ' + pdf_file)
time.sleep(1)
wpfApp = Application(backend=u'uia').connect(path=acrobat_path) # Reconnect
wind = wpfApp.windows()
title = wind[0].get_properties()[u'texts'][0] # retrive Title of window
app_wind = wpfApp.window(title = title) #get access tp main window
app_menu = app_wind.children(title="Application", control_type="MenuBar") #get access to app menu
app_menu[0].children(title="File")[0].click_input() #click on File Menu
file_menu = app_wind.children(title="File", control_type="Menu") #get access to file menu window
file_menu[0].children(title="Print... Ctrl+P")[0].click_input() #click on Print
time.sleep(5) #wait for print dialog to open
'''