pywinauto.controls.uia_controls

Wrap various UIA windows controls

class pywinauto.controls.uia_controls.ButtonWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap a UIA-compatible Button, CheckBox or RadioButton control

click()

Click the Button control by using Invoke or Select patterns

get_toggle_state()

Get a toggle state of a check box control.

The toggle state is represented by an integer 0 - unchecked 1 - checked 2 - indeterminate

The following constants are defined in the uia_defines module toggle_state_off = 0 toggle_state_on = 1 toggle_state_inderteminate = 2

is_dialog()

Buttons are never dialogs so return False

toggle()

An interface to Toggle method of the Toggle control pattern.

Control supporting the Toggle pattern cycles through its toggle states in the following order: ToggleState_On, ToggleState_Off and, if supported, ToggleState_Indeterminate

Usually applied for the check box control.

The radio button control does not implement IToggleProvider, because it is not capable of cycling through its valid states. Toggle a state of a check box control. (Use ‘select’ method instead) Notice, a radio button control isn’t supported by UIA. https://msdn.microsoft.com/en-us/library/windows/desktop/ee671290(v=vs.85).aspx

class pywinauto.controls.uia_controls.ComboBoxWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap a UIA CoboBox control

collapse()
expand()
get_expand_state()
is_editable()
item_count()

Return the number of items in the combobox

The interface is kept mostly for a backward compatibility with the native ComboBox interface

select(item)

Select the ComboBox item

The item can be either a 0 based index of the item to select or it can be the string that you want to select

selected_index()

Return the selected index

selected_text()

Return the selected text or None

Notice, that in case of multi-select it will be only the text from a first selected item

texts()

Return the text of the items in the combobox

class pywinauto.controls.uia_controls.EditWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible Edit control

get_line(line_index)

Return the line specified

get_value()

Return the current value of the element

has_title = False
is_editable()

Return the edit possibility of the element

line_count()

Return how many lines there are in the Edit

line_length(line_index)

Return how many characters there are in the line

select(start=0, end=None)

Set the edit selection of the edit control

selection_indices()

The start and end indices of the current selection

set_edit_text(text, pos_start=None, pos_end=None)

Set the text of the edit control

set_text(text, pos_start=None, pos_end=None)

Set the text of the edit control

set_window_text(text, append=False)

Override set_window_text for edit controls because it should not be used for Edit controls.

Edit Controls should either use set_edit_text() or type_keys() to modify the contents of the edit control.

text_block()

Get the text of the edit control

texts()

Get the text of the edit control

writable_props

Extend default properties list.

class pywinauto.controls.uia_controls.HeaderItemWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible Header Item control

class pywinauto.controls.uia_controls.HeaderWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible Header control

class pywinauto.controls.uia_controls.ListItemWrapper(elem, container=None)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible ListViewItem control

is_checked()

Return True if the ListItem is checked

Only items supporting Toggle pattern should answer. Raise NoPatternInterfaceError if the pattern is not supported

texts()

Return a list of item texts

class pywinauto.controls.uia_controls.ListViewWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible ListView control

cell(row, column)

Return a cell in the ListView control

Only for controls with Grid pattern support

  • row is an index of a row in the list.
  • column is an index of a column in the specified row.

The returned cell can be of different control types. Mostly: TextBlock, ImageControl, EditControl, DataItem or even another layer of data items (Group, DataGrid)

cells()

Return list of list of cells for any type of contol

column_count()

Return the number of columns

columns()

Get the information on the columns of the ListView

get_column(col_index)

Get the information for a column of the ListView

get_header_control()

Return Header control associated with the ListView

get_header_controls()

Return Header controls associated with the Table

get_item(row)

Return an item of the ListView control

  • row can be either an index of the row or a string with the text of a cell in the row you want returned.
get_item_rect(item_index)

Return the bounding rectangle of the list view item

The method is kept mostly for a backward compatibility with the native ListViewWrapper interface

get_items()

Return all items of the ListView control

get_selected_count()

Return a number of selected items

The call can be quite expensieve as we retrieve all the selected items in order to count them

item(row)

Return an item of the ListView control

  • row can be either an index of the row or a string with the text of a cell in the row you want returned.
item_count()

A number of items in the ListView

items()

Return all items of the ListView control

texts()

Return a list of item texts

writable_props

Extend default properties list.

class pywinauto.controls.uia_controls.MenuItemWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible MenuItem control

items()

Find all items of the menu item

select()

Apply Select pattern

class pywinauto.controls.uia_controls.MenuWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible MenuBar or Menu control

item_by_index(idx)

Find a menu item specified by the index

item_by_path(path, exact=False)

Find a menu item specified by the path

The full path syntax is specified in: controls.menuwrapper.Menu.get_menu_path()

Note: $ - specifier is not supported

items()

Find all menu items

class pywinauto.controls.uia_controls.SliderWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible Slider control

has_title = False
large_change()

Get a large change of slider’s thumb

This change is achieved by pressing PgUp and PgDown keys when slider’s thumb has keyboard focus.

max_value()

Get the maximum value of the Slider

min_value()

Get the minimum value of the Slider

set_value(value)

Set position of slider’s thumb

small_change()

Get a small change of slider’s thumb

This change is achieved by pressing left and right arrows when slider’s thumb has keyboard focus.

value()

Get a current position of slider’s thumb

class pywinauto.controls.uia_controls.StaticWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible Text control

can_be_label = True
class pywinauto.controls.uia_controls.TabControlWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible Tab control

get_selected_tab()

Return an index of a selected tab

select(item)

Select a tab by index or by name

tab_count()

Return a number of tabs

texts()

Tabs texts

class pywinauto.controls.uia_controls.ToolbarWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible ToolBar control

The control’s children usually are: Buttons, SplitButton, MenuItems, ThumbControls, TextControls, Separators, CheckBoxes. Notice that ToolTip controls are children of the top window and not of the toolbar.

button(button_identifier, exact=True)

Return a button by the specified identifier

  • button_identifier can be either an index of a button or a string with the text of the button.
  • exact flag specifies if the exact match for the text look up has to be applied.
button_count()

Return a number of buttons on the ToolBar

buttons()

Return all available buttons

check_button(button_identifier, make_checked, exact=True)

Find where the button is and toggle it

  • button_identifier can be either an index of the button or a string with the text on the button.
  • make_checked specifies the required toggled state of the button. If the button is already in the specified state the state isn’t changed.
  • exact flag specifies if the exact match for the text look up has to be applied
texts()

Return texts of the Toolbar

writable_props

Extend default properties list.

class pywinauto.controls.uia_controls.TooltipWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible Tooltip control

class pywinauto.controls.uia_controls.TreeItemWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible TreeItem control

In addition to the provided methods of the wrapper additional inherited methods can be especially helpful: select(), extend(), collapse(), is_extended(), is_collapsed(), click_input(), rectangle() and many others

ensure_visible()

Make sure that the TreeView item is visible

get_child(child_spec, exact=False)

Return the child item of this item

Accepts either a string or an index. If a string is passed then it returns the child item with the best match for the string.

is_checked()

Return True if the TreeItem is checked

Only items supporting Toggle pattern should answer. Raise NoPatternInterfaceError if the pattern is not supported

sub_elements()

Return a list of all visible sub-items of this control

class pywinauto.controls.uia_controls.TreeViewWrapper(elem)

Bases: pywinauto.controls.uiawrapper.UIAWrapper

Wrap an UIA-compatible Tree control

get_item(path, exact=False)

Read a TreeView item

  • path a path to the item to return. This can be one of the following:
    • A string separated by \ characters. The first character must be \. This string is split on the \ characters and each of these is used to find the specific child at each level. The \ represents the root item - so you don’t need to specify the root itself.
    • A list/tuple of strings - The first item should be the root element.
    • A list/tuple of integers - The first item the index which root to select. Indexing always starts from zero: get_item((0, 2, 3))
  • exact a flag to request exact match of strings in the path or apply a fuzzy logic of best_match thus allowing non-exact path specifiers
item_count()

Return a number of items in TreeView

print_items()

Print all items with line indents

roots()

Return root elements of TreeView

writable_props

Extend default properties list.