Невозможно выполнить действие над ComBox с помощью PyWinAuto - PullRequest
0 голосов
/ 10 июля 2020

Я пытаюсь получить доступ к комбинированному списку в приложении, но не могу. Ниже мой код

from pywinauto.application import Application
from pywinauto import mouse
from pywinauto import keyboard
import pywinauto
import time
import os
import subprocess
main_window = app.window(title = "XXXXXXXXXXXXXXXX", control_type = "Window")
main_window.child_window(title = 'XXXXXXXXXXXXXX', control_type = "Window").child_window\
(title = 'Classification', control_type = "Group", found_index = 1).ComboBox6.select("Deep")

Вот мой список идентификаторов элементов управления:

Here is my Control_Identifiers list -

    GroupBox - 'Classification'    (L-1193, T166, R-726, B504)
['ClassificationGroupBox', 'GroupBox', 'Classification', 'GroupBox0', 'GroupBox1']
child_window(title="Classification", control_type="Group")
   |
   | Custom - ''    (L-1191, T187, R-728, B502)
   | ['Custom', 'ClassCustom', 'Custom0', 'Custom1', 'ClassCustom0', 'ClassCustom1']
   |    |
   |    | GroupBox - ''    (L-1191, T187, R-728, B502)
   |    | ['GroupBox2', 'ClassGroupBox']
   |    |    |
   |    |    | Table - ''    (L-1182, T197, R-1022, B492)
   |    |    | ['Table']
   |    |    |    |
   |    |    |    | Pane - ''    (L0, T0, R0, B0)
   |    |    |    | ['Pane']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1180, T199, R-1141, B236)
   |    |    |    | ['DataItem', 'DataItem0', 'DataItem1']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1141, T199, R-1102, B236)
   |    |    |    | ['DataItem2']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1102, T199, R-1063, B236)
   |    |    |    | ['DataItem3']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1063, T199, R-1024, B236)
   |    |    |    | ['DataItem4']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1180, T236, R-1141, B273)
   |    |    |    | ['DataItem5']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1141, T236, R-1102, B273)
   |    |    |    | ['DataItem6']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1102, T236, R-1063, B273)
   |    |    |    | ['DataItem7']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1063, T236, R-1024, B273)
   |    |    |    | ['DataItem8']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1180, T273, R-1141, B310)
   |    |    |    | ['DataItem9']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1141, T273, R-1102, B310)
   |    |    |    | ['DataItem10']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1102, T273, R-1063, B310)
   |    |    |    | ['DataItem11']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1063, T273, R-1024, B310)
   |    |    |    | ['DataItem12']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1180, T310, R-1141, B346)
   |    |    |    | ['DataItem13']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1141, T310, R-1102, B346)
   |    |    |    | ['DataItem14']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1102, T310, R-1063, B346)
   |    |    |    | ['DataItem15']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1063, T310, R-1024, B346)
   |    |    |    | ['DataItem16']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1180, T346, R-1141, B382)
   |    |    |    | ['DataItem17']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1141, T346, R-1102, B382)
   |    |    |    | ['DataItem18']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1102, T346, R-1063, B382)
   |    |    |    | ['DataItem19']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1063, T346, R-1024, B382)
   |    |    |    | ['DataItem20']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1180, T382, R-1141, B418)
   |    |    |    | ['DataItem21']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1141, T382, R-1102, B418)
   |    |    |    | ['DataItem22']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1102, T382, R-1063, B418)
   |    |    |    | ['DataItem23']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1063, T382, R-1024, B418)
   |    |    |    | ['DataItem24']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1180, T418, R-1141, B454)
   |    |    |    | ['DataItem25']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1141, T418, R-1102, B454)
   |    |    |    | ['DataItem26']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1102, T418, R-1063, B454)
   |    |    |    | ['DataItem27']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1063, T418, R-1024, B454)
   |    |    |    | ['DataItem28']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1180, T454, R-1141, B490)
   |    |    |    | ['DataItem29']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1141, T454, R-1102, B490)
   |    |    |    | ['DataItem30']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1102, T454, R-1063, B490)
   |    |    |    | ['DataItem31']
   |    |    |    |
   |    |    |    | DataItem - ''    (L-1063, T454, R-1024, B490)
   |    |    |    | ['DataItem32']
   |    |    |
   |    |    | Custom - ''    (L-1016, T196, R-737, B493)
   |    |    | ['Custom2', 'ClassCustom2']
   |    |    |    |
   |    |    |    | Static - 'Class'    (L-1014, T198, R-959, B218)
   |    |    |    | ['Static', 'ClassStatic', 'Class', 'Static0', 'Static1']
   |    |    |    | child_window(title="Class", control_type="Text")
   |    |    |    |
   |    |    |    | Static - 'Model'    (L-1014, T348, R-959, B368)
   |    |    |    | ['Model', 'ModelStatic', 'Static2']
   |    |    |    | child_window(title="Model", control_type="Text")
   |    |    |    |
   |    |    |    | ComboBox - ''    (L-949, T348, R-739, B368)
   |    |    |    | ['ComboBox', 'ComboBoxAN/SSQ981B', 'ComboBoxAN/SSQ981E', 'ModelComboBox', 'ComboBoxAN/SSQ981', 'ComboBox1', 'ComboBox0']
   |    |    |    |    |
   |    |    |    |    | ListBox - ''    (L0, T0, R0, B0)
   |    |    |    |    | ['ListBox', 'ListBox0', 'ListBox1']
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'AN/SSQ801'    (L-947, T369, R-741, B382)
   |    |    |    |    |    | ['AN/SSQ801', 'AN/SSQ801ListItem', 'ListItem', 'ListItem0', 'ListItem1']
   |    |    |    |    |    | child_window(title="AN/SSQ801", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'AN/SSQ981'    (L-947, T382, R-741, B395)
   |    |    |    |    |    | ['AN/SSQ981', 'ListItem2', 'AN/SSQ981ListItem']
   |    |    |    |    |    | child_window(title="AN/SSQ981", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'AN/SSQ981B'    (L-947, T395, R-741, B408)
   |    |    |    |    |    | ['AN/SSQ981B', 'ListItem3', 'AN/SSQ981BListItem']
   |    |    |    |    |    | child_window(title="AN/SSQ981B", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'AN/SSQ981E'    (L-947, T408, R-741, B421)
   |    |    |    |    |    | ['ListItem4', 'AN/SSQ981E', 'AN/SSQ981EListItem']
   |    |    |    |    |    | child_window(title="AN/SSQ981E", control_type="ListItem")
   |    |    |    |
   |    |    |    | Edit - 'Z01'    (L-949, T258, R-739, B278)
   |    |    |    | ['NameEdit', 'Edit', 'Edit0', 'Edit1']
   |    |    |    | child_window(title="Z01", control_type="Edit")
   |    |    |    |
   |    |    |    | Edit - '22.0'    (L-867, T288, R-739, B308)
   |    |    |    | ['Depth (m)Edit', 'Edit2']
   |    |    |    | child_window(title="22.0", control_type="Edit")
   |    |    |    |
   |    |    |    | ComboBox - ''    (L-949, T318, R-877, B338)
   |    |    |    | ['ComboBox2', 'ComboBox3', 'ComboBox4', 'Life (hr)ComboBox']
   |    |    |    |    |
   |    |    |    |    | ListBox - ''    (L0, T0, R0, B0)
   |    |    |    |    | ['ListBox2']
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - '1/2'    (L-947, T339, R-879, B352)
   |    |    |    |    |    | ['1/2ListItem', 'ListItem5', '1/2']
   |    |    |    |    |    | child_window(title="1/2", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - '1'    (L-947, T352, R-879, B365)
   |    |    |    |    |    | ['ListItem6', '1', '1ListItem']
   |    |    |    |    |    | child_window(title="1", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - '2'    (L-947, T365, R-879, B378)
   |    |    |    |    |    | ['ListItem7', '2ListItem', '2']
   |    |    |    |    |    | child_window(title="2", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - '4'    (L-947, T378, R-879, B391)
   |    |    |    |    |    | ['4ListItem', 'ListItem8', '4']
   |    |    |    |    |    | child_window(title="4", control_type="ListItem")
   |    |    |    |
   |    |    |    | Edit - '2.0'    (L-867, T318, R-739, B338)
   |    |    |    | ['Edit3', 'Life (hr)Edit']
   |    |    |    | child_window(title="2.0", control_type="Edit")
   |    |    |    |
   |    |    |    | Static - 'Depth (m)'    (L-1014, T288, R-959, B308)
   |    |    |    | ['Depth (m)', 'Static3', 'Depth (m)Static']
   |    |    |    | child_window(title="Depth (m)", control_type="Text")
   |    |    |    |
   |    |    |    | ComboBox - ''    (L-949, T198, R-739, B218)
   |    |    |    | ['ClassComboBox', 'ComboBoxDICASS', 'ComboBox5', 'ComboBoxDIFAR', 'ComboBoxBARRA', 'ComboBoxHIDAR', 'ComboBoxBathy']
   |    |    |    |    |
   |    |    |    |    | ListBox - ''    (L0, T0, R0, B0)
   |    |    |    |    | ['ListBox3']
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'ANM'    (L-947, T219, R-741, B232)
   |    |    |    |    |    | ['ANM', 'ListItem9', 'ANMListItem']
   |    |    |    |    |    | child_window(title="ANM", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'DIFAR'    (L-947, T232, R-741, B245)
   |    |    |    |    |    | ['ListItem10', 'DIFAR', 'DIFARListItem']
   |    |    |    |    |    | child_window(title="DIFAR", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'HIDAR'    (L-947, T245, R-741, B258)
   |    |    |    |    |    | ['ListItem11', 'HIDAR', 'HIDARListItem']
   |    |    |    |    |    | child_window(title="HIDAR", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'BARRA'    (L-947, T258, R-741, B271)
   |    |    |    |    |    | ['ListItem12', 'BARRAListItem', 'BARRA']
   |    |    |    |    |    | child_window(title="BARRA", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'DICASS'    (L-947, T271, R-741, B284)
   |    |    |    |    |    | ['DICASSListItem', 'ListItem13', 'DICASS']
   |    |    |    |    |    | child_window(title="DICASS", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'Bathy'    (L-947, T284, R-741, B297)
   |    |    |    |    |    | ['Bathy', 'ListItem14', 'BathyListItem']
   |    |    |    |    |    | child_window(title="Bathy", control_type="ListItem")
   |    |    |    |
   |    |    |    | Static - 'Name'    (L-1014, T258, R-959, B278)
   |    |    |    | ['NameStatic', 'Name', 'Static4']
   |    |    |    | child_window(title="Name", control_type="Text")
   |    |    |    |
   |    |    |    | Static - 'Life (hr)'    (L-1014, T318, R-959, B338)
   |    |    |    | ['Life (hr)', 'Static5', 'Life (hr)Static']
   |    |    |    | child_window(title="Life (hr)", control_type="Text")
   |    |    |    |
   |    |    |    | Static - 'RF Channel'    (L-1014, T228, R-959, B248)
   |    |    |    | ['RF Channel', 'Static6', 'RF ChannelStatic']
   |    |    |    | child_window(title="RF Channel", control_type="Text")
   |    |    |    |
   |    |    |    | Edit - '1'    (L-949, T228, R-739, B248)
   |    |    |    | ['Edit4', 'RF ChannelEdit']
   |    |    |    | child_window(title="1", control_type="Edit")
   |    |    |    |
   |    |    |    | ComboBox - ''    (L-949, T288, R-877, B308)
   |    |    |    | ['ComboBoxDeep', 'Depth (m)ComboBox', 'ComboBox6']
   |    |    |    |    |
   |    |    |    |    | ListBox - ''    (L0, T0, R0, B0)
   |    |    |    |    | ['ListBox4']
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'Shallow'    (L-947, T309, R-879, B322)
   |    |    |    |    |    | ['ListItem15', 'Shallow', 'ShallowListItem']
   |    |    |    |    |    | child_window(title="Shallow", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'Deep'    (L-947, T322, R-879, B335)
   |    |    |    |    |    | ['ListItem16', 'Deep', 'DeepListItem']
   |    |    |    |    |    | child_window(title="Deep", control_type="ListItem")
   |
   | TabControl - 'Sensor'    (L-1193, T166, R-982, B187)
   | ['Sensor', 'TabControl', 'SensorTabControl', 'Sensor0', 'Sensor1']
   | child_window(title="Sensor", control_type="Tab")
   |    |
   |    | TabItem - 'Track'    (L-1193, T166, R-1143, B187)
   |    | ['TrackTabItem', 'Track', 'TabItem', 'TabItem0', 'TabItem1']
   |    | child_window(title="Track", control_type="TabItem")
   |    |
   |    | TabItem - 'Sensor'    (L-1143, T166, R-1086, B187)
   |    | ['TabItem2', 'Sensor2', 'SensorTabItem']
   |    | child_window(title="Sensor", control_type="TabItem")
   |    |
   |    | TabItem - 'Source'    (L-1086, T166, R-1029, B187)
   |    | ['Source', 'SourceTabItem', 'TabItem3']
   |    | child_window(title="Source", control_type="TabItem")
   |    |
   |    | TabItem - 'Mark'    (L-1029, T166, R-982, B187)
   |    | ['TabItem4', 'Mark', 'MarkTabItem']
   |    | child_window(title="Mark", control_type="TabItem")

Из чего у меня проблема с конкретным доступом ниже ComboBox:

ComboBox - ''    (L-949, T288, R-877, B308)
   |    |    |    | ['ComboBoxDeep', 'Depth (m)ComboBox', 'ComboBox6']
   |    |    |    |    |
   |    |    |    |    | ListBox - ''    (L0, T0, R0, B0)
   |    |    |    |    | ['ListBox4']
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'Shallow'    (L-947, T309, R-879, B322)
   |    |    |    |    |    | ['ListItem15', 'Shallow', 'ShallowListItem']
   |    |    |    |    |    | child_window(title="Shallow", control_type="ListItem")
   |    |    |    |    |    |
   |    |    |    |    |    | ListItem - 'Deep'    (L-947, T322, R-879, B335)
   |    |    |    |    |    | ['ListItem16', 'Deep', 'DeepListItem']
   |    |    |    |    |    | child_window(title="Deep", control_type="ListItem")

Я пробовал разные варианты, используя

main_window.child_window(title = 'Add ASD Object', control_type = "Window").child_window\
(title = 'Classification', control_type = "Group", found_index = 1).ComboBox6.ListBox4.child_window(title="Deep", control_type="ListItem").select(). 

Но ничего не работало. Я подозреваю, что, поскольку имя ComboBox включает пробелы, я не могу указать имя ComboBox, поэтому я не могу найти элементы ComboBox.

Здесь есть предложения?

...