我们如何检索Word文档的页眉和页脚文本

时间:2019-05-23 16:21:23

标签: pywinauto

我正在尝试使用pywinauto自动执行Windows加载项功能,并面临挑战以检索页眉和页脚文本。请帮助

使用pywinauto 0.6.5 平台Win10 Python 3.7

self.app = Application(backend='uia').start(r'C:\\Program Files (x86)\\Microsoft Office\\Office15\\winword.exe')
self.app.wait_cpu_usage_lower(threshold=5)  

self.main = self.app.window(title_re='.* - Word')

print(self.main.Document1.Footer.window_text())

Pane - 'Document1'    (L-8, T26, R1374, B714)
['Document1Pane', 'Pane', 'Document1', 'Pane0', 'Pane1']
child_window(title="Document1", control_type="Pane")
   |
   | Document - ''    (L0, T57, R1349, B706)
   | ['', 'Document', '0', '1']
   |    |
   |    | Custom - 'Page 1'    (L0, T0, R0, B0)
   |    | ['Page 1Custom', 'Page 1', 'Custom']
   |    | child_window(title="Page 1", auto_id="UIA_AutomationId_Word_Page_1", control_type="Custom")
   |    |    |
   |    |    | Edit - 'Header -Section 1-'    (L347, T144, R355, B160)
   |    |    | ['2', 'Edit', 'Edit0', 'Edit1']
   |    |    | child_window(title="Header -Section 1-", control_type="Edit")
   |    |    |    |
   |    |    |    | Image - 'Rectangle'    (L347, T1102, R614, B1112)
   |    |    |    | ['RectangleImage', 'Image', 'Rectangle']
   |    |    |    | child_window(title="Rectangle", control_type="Image")
   |    |    |
   |    |    | Edit - 'Page 1 content'    (L0, T0, R0, B0)
   |    |    | ['3', 'Edit2']
   |    |    | child_window(title="Page 1 content", auto_id="UIA_AutomationId_Word_Content_Page_1", control_type="Edit")
   |    |    |
   |    |    | Edit - 'Footer'    (L0, T0, R0, B0)
   |    |    | ['4', 'Edit3']
   |    |    | child_window(title="Footer", control_type="Edit")
   |
   | Pane - 'Vertical'    (L1349, T57, R1366, B706)
   | ['Pane2', 'Vertical', 'VerticalPane']
   | child_window(title="Vertical", control_type="Pane")
   |    |
   |    | Pane - ''    (L1349, T57, R1366, B706)
   |    | ['5', 'Pane3']
   |    |    |
   |    |    | ScrollBar - ''    (L1349, T57, R1366, B706)
   |    |    | ['ScrollBar', '6']
   |    |    |    |
   |    |    |    | Button - 'Line up'    (L1349, T57, R1366, B74)

0 个答案:

没有答案