pywinauto - найти / прочитать текст в диалоге / всплывающем окне, которое не является частью какого-либо элемента управления диалогового окна - PullRequest
0 голосов
/ 19 апреля 2020

Я пытаюсь прочитать текст «Это возвращение наступает раньше или раньше» из диалогового окна / всплывающего окна приложения, которое я пытаюсь автоматизировать с помощью pywinauto, я могу автоматизировать другие элементы управления в этом всплывающем окне. вверх, т.е. OK / Close / et c., просто не удалось добраться до «текста», и я попробовал приведенный ниже код, но кажется, что этот текст не является частью какого-либо элемента управления диалогового окна, поэтому есть ли другие как я могу добраться до текста? Диалог / всплывающее окно

Inspect.exe показывает это для всплывающего окна inspect_exe_data

Я пробовал код ниже:

from pywinauto.application import Application
app = Application(backend="win32").start("app.exe")
#This is the dialog with the text i am after
dialog=app.RTI
dialog.window_text()
dialog.texts()
dialog.print_control_identifiers()
dialog.children()
dialog.descendants()
for child in dialog.descendants():
 print (child.window_text())
 print (child.texts())

вывод:

>>> dialog.window_text()
'RTI'
>>> dialog.texts()
['RTI']
>>> dialog.print_control_identifiers()
Control Identifiers:

Tdlg_askbox - 'RTI'    (L711, T344, R1208, B482)
['Tdlg_askbox', 'RTI', 'RTITdlg_askbox']
child_window(title="RTI", class_name="Tdlg_askbox")
   |
   | ComboBox - ''    (L723, T503, R1196, B535)
   | ['RTIComboBox', 'ComboBox']
   | child_window(class_name="TComboBox")
   |
   | Edit - ''    (L723, T465, R1196, B497)
   | ['Edit', 'RTIEdit']
   | child_window(class_name="TEdit")
   |
   | CheckBox - 'Don't ask me this again'    (L723, T641, R1196, B667)
   | ['CheckBox', "Don't ask me this againCheckBox", "Don't ask me this again"]
   | child_window(title="Don't ask me this again", class_name="TCheckBox")
   |
   | Button - 'Help'    (L843, T432, R956, B470)
   | ['Help', 'HelpButton', 'Button', 'Button0', 'Button1']
   | child_window(title="Help", class_name="TButton")
   |
   | Button - 'Cancel'    (L723, T596, R836, B634)
   | ['Cancel', 'CancelButton', 'Button2']
   | child_window(title="Cancel", class_name="TButton")
   |
   | Button - 'OK'    (L963, T432, R1076, B470)
   | ['OK', 'Button3', 'OKButton']
   | child_window(title="OK", class_name="TButton")
   |
   | Button - '&No'    (L963, T551, R1076, B589)
   | ['&NoButton', 'Button4', '&No']
   | child_window(title="&No", class_name="TButton")
   |
   | Button - '&Yes'    (L843, T551, R956, B589)
   | ['&Yes', '&YesButton', 'Button5']
   | child_window(title="&Yes", class_name="TButton")
>>> dialog.children()
[<win32_controls.ComboBoxWrapper - '', ComboBox, 265638>, <win32_controls.EditWrapper - '', Edit, 265636>, <win32_controls.ButtonWrapper - 'Don't ask me this again', CheckBox, 265634>, <win32_controls.ButtonWrapper - 'Help', Button, 265632>, <win32_controls.ButtonWrapper - 'Cancel', Button, 265630>, <win32_controls.ButtonWrapper - 'OK', Button, 265628>, <win32_controls.ButtonWrapper - '&No', Button, 265626>, <win32_controls.ButtonWrapper - '&Yes', Button, 265624>]
>>> dialog.descendants()
[<win32_controls.ComboBoxWrapper - '', ComboBox, 265638>, <win32_controls.EditWrapper - '', Edit, 265636>, <win32_controls.ButtonWrapper - 'Don't ask me this again', CheckBox, 265634>, <win32_controls.ButtonWrapper - 'Help', Button, 265632>, <win32_controls.ButtonWrapper - 'Cancel', Button, 265630>, <win32_controls.ButtonWrapper - 'OK', Button, 265628>, <win32_controls.ButtonWrapper - '&No', Button, 265626>, <win32_controls.ButtonWrapper - '&Yes', Button, 265624>]
>>> for child in dialog.descendants():
...  print (child.window_text())
...  print (child.texts())
...

['']

['', '']
Don't ask me this again
["Don't ask me this again"]
Help
['Help']
Cancel
['Cancel']
OK
['OK']
&No
['&No']
&Yes
['&Yes']
...