Python-pywinauto iface_value.GetValue()不起作用,是因为所选窗口没有此类属性吗?
我正在自动化基于c#的应用程序,其中嵌入了一些网页。我试图使用dlg_list.iface_value.GetValue()从页面的表中获取数据值,错误如下:Python-pywinauto iface_value.GetValue()不起作用,是因为所选窗口没有此类属性吗?,python,pywinauto,Python,Pywinauto,我正在自动化基于c#的应用程序,其中嵌入了一些网页。我试图使用dlg_list.iface_value.GetValue()从页面的表中获取数据值,错误如下: D:\app\python\lib\site-packages\comtypes__init__.py", line 275, in getattr fixed_name = self.map_case[name.lower()] KeyError: 'getvalue' During handling of the above e
D:\app\python\lib\site-packages\comtypes__init__.py", line 275, in getattr
fixed_name = self.map_case[name.lower()]
KeyError: 'getvalue'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/app/pyprojects/smart/Patient_Registry/Go2Calling.py", line 9, in dlg_list.iface_value.GetValue()
File "D:\app\python\lib\site-packages\comtypes__init__.py", line 277, in getattr
raise AttributeError(name) AttributeError: GetValue
dlg_list是可以用.draw_outline()突出显示的记录之一,我试图获取该记录的值
Pywinauto不再有GetValue()
2020年3月24日更新:
row1 = dlg.child_window(title="name row 0").wrapper_object()
dir(row1)
D:\app\pyprojects\smart\venv\Scripts\python.exe D:/app/pyprojects/smart/Patient_Registry/Triage.py
['__abstractmethods__', '__class__', '__delattr__', '__dict__', '__dir__',
'__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__',
'__hash__', '__init__', '__init_subclass__', '__le__', '__lt__',
'__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__',
'__weakref__', '_abc_impl', '_as_parameter_', '_cache',
'_calc_click_coords', '_control_types', '_create_wrapper', '_element_info',
'_needs_image_prop', '_select', 'actions', 'appdata', 'backend',
'can_be_label', 'can_select_multiple', 'capture_as_image', 'children',
'children_texts', 'class_name', 'click_input', 'client_to_screen', 'close',
'collapse', 'container', 'control_count', 'control_id', 'descendants',
'double_click_input', 'drag_mouse_input', 'draw_outline', 'element_info',
'expand', 'friendly_class_name', 'friendlyclassname', 'get_expand_state',
'get_properties', 'get_selection', 'handle', 'has_keyboard_focus',
'has_title', 'iface_expand_collapse', 'iface_grid', 'iface_grid_item',
'iface_invoke', 'iface_item_container', 'iface_range_value',
'iface_scroll_item', 'iface_selection', 'iface_selection_item',
'iface_table', 'iface_table_item', 'iface_text', 'iface_toggle',
'iface_value', 'iface_virtualized_item', 'iface_window', 'invoke',
'is_active', 'is_checked', 'is_child', 'is_collapsed', 'is_dialog',
'is_enabled', 'is_expanded', 'is_keyboard_focusable', 'is_selected',
'is_selection_required', 'is_visible', 'maximize', 'menu_select',
'minimize', 'move_mouse_input', 'parent', 'press_mouse_input', 'process_id',
'rectangle', 'ref', 'release_mouse_input', 'right_click_input', 'root',
'select', 'selected_item_index', 'set_focus', 'texts', 'top_level_parent',
'type_keys', 'verify_actionable', 'verify_enabled', 'verify_visible',
'wait_for_idle', 'wheel_mouse_input', 'window_text', 'windowclasses',
'writable_props']
Avery:iface\u value
存在,但当我尝试dlg.child\u窗口(title=“name row 0”)。iface\u value.GetValue()
完整的错误消息是这样的
D:\app\pyprojects\smart\venv\Scripts\python.exe D:/app/pyprojects/smart/Patient_Registry/Triage.py
Traceback (most recent call last):
File "D:\app\python\lib\site-packages\comtypes\__init__.py", line 275, in __getattr__
fixed_name = self.__map_case__[name.lower()]
KeyError: 'getvalue'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/app/pyprojects/smart/Patient_Registry/Triage.py", line 35, in <module>
dlg.child_window(title="name row 0").iface_value.GetValue()
File "D:\app\python\lib\site-packages\comtypes\__init__.py", line 277, in __getattr__
raise AttributeError(name)
AttributeError: GetValue
Process finished with exit code 1
D:\app\pyprojects\smart\venv\Scripts\python.exe D:/app/pyprojects/smart/Patient\u Registry/Triage.py
回溯(最近一次呼叫最后一次):
文件“D:\app\python\lib\site packages\comtypes\\uuuuu init\uuuuuu.py”,第275行,在\uuuu getattr中__
已修复\u name=self.\u映射\u大小写\u[name.lower()]
KeyError:'getvalue'
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“D:/app/pyprojects/smart/Patient_Registry/Triage.py”,第35行,在
dlg.child_窗口(title=“name row 0”).iface_value.GetValue()
文件“D:\app\python\lib\site packages\comtypes\\uuuuu init\uuuuuu.py”,第277行,在\uuuu getattr中__
提升属性错误(名称)
AttributeError:GetValue
进程已完成,退出代码为1
我还尝试了
dir(var.wrapper\u object().iface\u value)
,列表中没有GetValue
,CurrentValue
似乎满足了我的要求。ValuePattern
和legaciiaccessiblepattern
是不同的。如果在“UI自动化”模式下运行Inspect.exe
,并看到元素支持旧模式,则可以使用包装器对象方法.legacy\u properties()
,该方法返回旧属性字典。目前,这些属性不能用作.child\u window(…)
规范中的关键字(将在下一个主要版本中实现)
ValuePattern
支持意味着您需要.iface\u value.CurrentValue
或包装方法.get\u value()
那么,ValuePattern
和LegacyIAccessiblePattern
是不同的。如果在“UI自动化”模式下运行Inspect.exe
,并看到元素支持旧模式,则可以使用包装器对象方法.legacy\u properties()
,该方法返回旧属性字典。目前,这些属性不能用作.child\u window(…)
规范中的关键字(将在下一个主要版本中实现)
ValuePattern
支持意味着您需要.iface\u value.CurrentValue
或包装方法.get\u value()
我可以假设此元素不支持ValuePattern,但在这种情况下,它将引发NoPatternInterface
异常。请将.iface\u value
返回到一个变量,并调用dir(var)
列出所有可用的属性。我已添加到dir(var)中,但我可以在检查窗口中看到以下键值:value.value:“Jack Donald”\n LegacyIAccessible.value:“Jack Donald”尝试了另一个元素,它返回**文件“D:/app/pyprojects/smart/login.py”,edit0.iface\u value.GetValue()AttributeError中的第44行:“EditWrapper”对象没有属性“iface\u value”**dir()
显示了WindowSpecification
的方法。请先调用.wrapper\u object()
,然后调用dir(wrapper)
。发布完整的错误消息非常重要。特别是对于属性错误
。我猜当前错误消息未满。我可以假定此元素不支持ValuePattern,但在这种情况下,它将引发NoPatternInterface
异常。请将.iface\u value
返回到一个变量,并调用dir(var)
列出所有可用的属性。我已添加到dir(var)中,但我可以在检查窗口中看到以下键值:value.value:“Jack Donald”\n LegacyIAccessible.value:“Jack Donald”尝试了另一个元素,它返回**文件“D:/app/pyprojects/smart/login.py”,edit0.iface\u value.GetValue()AttributeError中的第44行:“EditWrapper”对象没有属性“iface\u value”**dir()
显示了WindowSpecification
的方法。请先调用.wrapper\u object()
,然后调用dir(wrapper)
。发布完整的错误消息非常重要。特别是对于属性错误
。我猜当前的错误消息不完整。