pywinauto.controls.uiawrapper¶
Basic wrapping of UI Automation elements
- class
pywinauto.controls.uiawrapper.
LazyProperty
(fget)¶Bases:
object
A lazy evaluation of an object attribute.
The property should represent immutable data, as it replaces itself. Provided by: http://stackoverflow.com/a/6849299/1260742
- class
pywinauto.controls.uiawrapper.
UIAWrapper
(element_info)¶Bases:
pywinauto.base_wrapper.BaseWrapper
Default wrapper for User Interface Automation (UIA) controls.
All other UIA wrappers are derived from this.
This class wraps a lot of functionality of underlying UIA features for working with windows.
Most of the methods apply to every single element type. For example you can click() on any element.
automation_id
()¶Return the Automation ID of the control
can_select_multiple
()¶An interface to CanSelectMultiple of the SelectionProvider pattern
Indicates whether the UI Automation provider allows more than one child element to be selected concurrently.
children_texts
()¶Get texts of the control’s children
close
()¶Close the window
Only a control supporting Window pattern should answer. If it doesn’t (menu shadows, tooltips,...), try to send “Esc” key
collapse
()¶Displays all child nodes, controls, or content of the control
An interface to Collapse method of the ExpandCollapse control pattern.
expand
()¶Displays all child nodes, controls, or content of the control
An interface to Expand method of the ExpandCollapse control pattern.
friendly_class_name
()¶Return the friendly class name for the control
This differs from the class of the control in some cases. class_name() is the actual ‘Registered’ window class of the control while friendly_class_name() is hopefully something that will make more sense to the user.
For example Checkboxes are implemented as Buttons - so the class of a CheckBox is “Button” - but the friendly class is “CheckBox”
get_expand_state
()¶Indicates the state of the control: expanded or collapsed.
An interface to CurrentExpandCollapseState property of the ExpandCollapse control pattern. Values for enumeration as defined in uia_defines module: expand_state_collapsed = 0 expand_state_expanded = 1 expand_state_partially = 2 expand_state_leaf_node = 3
get_selection
()¶An interface to GetSelection of the SelectionProvider pattern
Retrieves a UI Automation provider for each child element that is selected. Builds a list of UIAElementInfo elements from all retrieved providers.
get_show_state
()¶Get the show state and Maximized/minimzed/restored state
Returns values as following
window_visual_state_normal = 0 window_visual_state_maximized = 1 window_visual_state_minimized = 2
has_keyboard_focus
()¶Return True if the element is focused with keyboard
iface_expand_collapse
= None¶
iface_grid
= None¶
iface_grid_item
= None¶
iface_invoke
= None¶
iface_item_container
= None¶
iface_range_value
= None¶
iface_scroll
= None¶
iface_scroll_item
= None¶
iface_selection
= None¶
iface_selection_item
= None¶
iface_table
= None¶
iface_table_item
= None¶
iface_text
= None¶
iface_toggle
= None¶
iface_transform
= None¶
iface_transformV2
= None¶
iface_value
= None¶
iface_virtualized_item
= None¶
iface_window
= None¶
invoke
()¶An interface to the Invoke method of the Invoke control pattern
is_active
()¶Whether the window is active or not
is_collapsed
()¶Test if the control is collapsed
is_dialog
()¶Return true if the control is a dialog window (WindowPattern interface is available)
is_expanded
()¶Test if the control is expanded
is_keyboard_focusable
()¶Return True if the element can be focused with keyboard
is_maximized
()¶Indicate whether the window is maximized or not
is_minimized
()¶Indicate whether the window is minimized or not
is_normal
()¶Indicate whether the window is normal (i.e. not minimized and not maximized)
is_selected
()¶Indicate that the item is selected or not.
Only items supporting SelectionItem pattern should answer. Raise NoPatternInterfaceError if the pattern is not supported
Usually applied for controls like: a radio button, a tree view item, a list item.
is_selection_required
()¶An interface to IsSelectionRequired property of the SelectionProvider pattern.
This property can be dynamic. For example, the initial state of a control might not have any items selected by default, meaning that IsSelectionRequired is FALSE. However, after an item is selected the control must always have at least one item selected.
legacy_properties
()¶Get the element’s LegacyIAccessible control pattern interface properties
maximize
()¶Maximize the window
Only controls supporting Window pattern should answer
Select a menu item specified in the path
The full path syntax is specified in:
pywinauto.menuwrapper.Menu.get_menu_path()
There are usually at least two menu bars: “System” and “Application” System menu bar is a standard window menu with items like: ‘Restore’, ‘Move’, ‘Size’, ‘Minimize’, e.t.c. This menu bar usually has a “Title Bar” control as a parent. Application menu bar is often what we look for. In most cases, its parent is the dialog itself so it should be found among the direct children of the dialog. Notice that we don’t use “Application” string as a title criteria because it couldn’t work on applications with a non-english localization. If there is no menu bar has been found we fall back to look up for Menu control. We try to find the control through all descendants of the dialog
minimize
()¶Minimize the window
Only controls supporting Window pattern should answer
restore
()¶Restore the window to normal size
Only controls supporting Window pattern should answer
scroll
(direction, amount, count=1, retry_interval=0.1)¶Ask the control to scroll itself
direction can be any of “up”, “down”, “left”, “right” amount can be only “line” or “page” count (optional) the number of times to scroll retry_interval (optional) interval between scroll actions
select
()¶Select the item
Only items supporting SelectionItem pattern should answer. Raise NoPatternInterfaceError if the pattern is not supported
Usually applied for controls like: a radio button, a tree view item or a list item.
selected_item_index
()¶Return the index of a selected item
set_focus
()¶Set the focus to this element
writable_props
¶Extend default properties list.
- class
pywinauto.controls.uiawrapper.
UiaMeta
(name, bases, attrs)¶Bases:
pywinauto.base_wrapper.BaseMeta
Metaclass for UiaWrapper objects
- static
find_wrapper
(element)¶Find the correct wrapper for this UIA element
pywinauto.controls.uiawrapper.
lazy_property
¶alias of
LazyProperty