pywinauto.controls.win32_controls

Wraps various standard windows controls

class pywinauto.controls.win32_controls.ButtonWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Wrap a windows Button control

Check()

Check a checkbox

CheckByClick()

Check the CheckBox control by click() method

CheckByClickInput()

Check the CheckBox control by click_input() method

GetCheckState()

Return the check state of the checkbox

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

The following constants are defined in the win32defines module BST_UNCHECKED = 0 BST_CHECKED = 1 BST_INDETERMINATE = 2

SetCheckIndeterminate()

Set the checkbox to indeterminate

UnCheck()

Uncheck a checkbox

UncheckByClick()

Uncheck the CheckBox control by click() method

UncheckByClickInput()

Uncheck the CheckBox control by click_input() method

can_be_label = True
check()

Check a checkbox

check_by_click()

Check the CheckBox control by click() method

check_by_click_input()

Check the CheckBox control by click_input() method

click(*args, **kwargs)

Click the Button control

friendly_class_name()

Return the friendly class name of the button

Windows controls with the class “Button” can look like different controls based on their style. They can look like the following controls:

  • Buttons, this method returns “Button”
  • CheckBoxes, this method returns “CheckBox”
  • RadioButtons, this method returns “RadioButton”
  • GroupBoxes, this method returns “GroupBox”
friendlyclassname = 'Button'
get_check_state()

Return the check state of the checkbox

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

The following constants are defined in the win32defines module BST_UNCHECKED = 0 BST_CHECKED = 1 BST_INDETERMINATE = 2

is_dialog()

Buttons are never dialogs so return False

set_check_indeterminate()

Set the checkbox to indeterminate

uncheck()

Uncheck a checkbox

uncheck_by_click()

Uncheck the CheckBox control by click() method

uncheck_by_click_input()

Uncheck the CheckBox control by click_input() method

windowclasses = ['Button', '.*Button', 'WindowsForms\\d*\\.BUTTON\\..*', '.*CheckBox']
class pywinauto.controls.win32_controls.ComboBoxWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Wrap a windows ComboBox control

DroppedRect()

Get the dropped rectangle of the combobox

ItemCount()

Return the number of items in the combobox

ItemData(item)

Returns the item data associated with the item if any

ItemTexts()

Return the text of the items of the combobox

Select(item)

Select the ComboBox item

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

SelectedIndex()

Return the selected index

SelectedText()

Return the selected text

dropped_rect()

Get the dropped rectangle of the combobox

friendlyclassname = 'ComboBox'
get_properties()

Return the properties of the control as a dictionary

has_title = False
item_count()

Return the number of items in the combobox

item_data(item)

Returns the item data associated with the item if any

item_texts()

Return the text of the items of the combobox

select(item)

Select the ComboBox item

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

texts()

Return the text of the items in the combobox

windowclasses = ['ComboBox', 'WindowsForms\\d*\\.COMBOBOX\\..*', '.*ComboBox']
writable_props

Extend default properties list.

class pywinauto.controls.win32_controls.EditWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Wrap a windows Edit control

GetLine(line_index)

Return the line specified

LineCount()

Return how many lines there are in the Edit

LineLength(line_index)

Return how many characters there are in the line

Select(start=0, end=None)

Set the edit selection of the edit control

SelectionIndices()

The start and end indices of the current selection

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

Set the text of the edit control

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

Set the text of the edit control

TextBlock()

Get the text of the edit control

friendlyclassname = 'Edit'
get_line(line_index)

Return the line specified

has_title = False
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

windowclasses = ['Edit', '.*Edit', 'TMemo', 'WindowsForms\\d*\\.EDIT\\..*', 'ThunderTextBox', 'ThunderRT6TextBox']
writable_props

Extend default properties list.

class pywinauto.controls.win32_controls.ListBoxWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Wrap a windows ListBox control

GetItemFocus()

Retrun the index of current selection in a ListBox

IsSingleSelection()

Check whether the listbox has single selection mode.

ItemCount()

Return the number of items in the ListBox

ItemData(i)

Return the item_data if any associted with the item

ItemRect(item)

Return the rect of the item

ItemTexts()

Return the text of the items of the listbox

Select(item, select=True)

Select the ListBox item

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

SelectedIndices()

The currently selected indices of the listbox

SetItemFocus(item)

Set the ListBox focus to the item at index

friendlyclassname = 'ListBox'
get_item_focus()

Retrun the index of current selection in a ListBox

has_title = False
is_single_selection()

Check whether the listbox has single selection mode.

item_count()

Return the number of items in the ListBox

item_data(i)

Return the item_data if any associted with the item

item_rect(item)

Return the rect of the item

item_texts()

Return the text of the items of the listbox

select(item, select=True)

Select the ListBox item

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_indices()

The currently selected indices of the listbox

set_item_focus(item)

Set the ListBox focus to the item at index

texts()

Return the texts of the control

windowclasses = ['ListBox', 'WindowsForms\\d*\\.LISTBOX\\..*', '.*ListBox']
writable_props

Extend default properties list.

class pywinauto.controls.win32_controls.PopupMenuWrapper(element_info)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Wrap a Popup Menu

friendlyclassname = 'PopupMenu'
has_title = False
is_dialog()

Return whether it is a dialog

windowclasses = ['#32768']
class pywinauto.controls.win32_controls.StaticWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Wrap a windows Static control

can_be_label = True
friendlyclassname = 'Static'
windowclasses = ['Static', 'WindowsForms\\d*\\.STATIC\\..*', 'TPanel', '.*StaticText']