pywinauto.controls.common_controls

Classes that wrap the Windows Common controls

class pywinauto.controls.common_controls._toolbar_button(index_, tb_handle)

Bases: object

Wrapper around Toolbar button (TBBUTTONINFO) items

click(button='left', pressed='')

Click on the Toolbar button

click_input(button='left', double=False, wheel_dist=0, pressed='')

Click on the Toolbar button

has_style(style)

Return True if the button has the specified style

is_checkable()

Return if the button can be checked

is_checked()

Return if the button is in the checked state

is_enabled()

Return if the button is in the pressed state

is_pressable()

Return if the button can be pressed

is_pressed()

Return if the button is in the pressed state

rectangle()

Get the rectangle of a button on the toolbar

state()

Return the state of the button

style()

Return the style of the button

text()

Return the text of the button

class pywinauto.controls.common_controls._treeview_element(elem, tv_handle)

Bases: object

Wrapper around TreeView items

children()

Return the direct children of this control

click(button='left', double=False, where='text', pressed='')

Click on the treeview item

where can be any one of “text”, “icon”, “button”, “check” defaults to “text”

click_input(button='left', double=False, wheel_dist=0, where='text', pressed='')

Click on the treeview item

where can be any one of “text”, “icon”, “button”, “check” defaults to “text”

client_rect(text_area_rect=True)

Return a rectangle of a text area of the item

If text_area_rect is set to False then it will return a rectangle for the whole item (usually left is equal to 0). Defaults to True - which returns just the rectangle of the text of the item

collapse()

Collapse the children of this tree view item

drop(button='left', pressed='')

Drop at the item

ensure_visible()

Make sure that the TreeView item is visible

expand()

Expand the children of this tree view item

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 whether the TreeView item is checked or not

is_expanded()

Indicate that the TreeView item is selected or not

is_selected()

Indicate that the TreeView item is selected or not

item()

Return the item itself

next_item()

Return the next item

select()

Select the TreeView item

start_dragging(button='left', pressed='')

Start dragging the item

state()

Return the state of the item

sub_elements()

Return the list of children of this control

text()

Return the text of the item

class pywinauto.controls.common_controls._listview_item(lv_ctrl, item_index, subitem_index=0)

Bases: object

Wrapper around ListView items

check()

Check the ListView item

click(button='left', double=False, where='text', pressed='')

Click on the list view item

where can be any one of “all”, “icon”, “text”, “select”, “check” defaults to “text”

click_input(button='left', double=False, wheel_dist=0, where='text', pressed='')

Click on the list view item

where can be any one of “all”, “icon”, “text”, “select”, “check” defaults to “text”

deselect()

Mark the item as not selected

The ListView control must be enabled and visible before an Item can be selected otherwise an exception is raised

ensure_visible()

Make sure that the ListView item is visible

image()

Return the image index of the item

indent()

Return the indent of the item

inplace_control(friendly_class_name='')

Return the editor HwndWrapper of the item

Possible friendly_class_name values:

  • "" Return the first appeared in-place control
  • "friendlyclassname" Returns editor with particular friendlyclassname
is_checked()

Return whether the ListView item is checked or not

is_focused()

Return True if the item has the focus

is_selected()

Return True if the item is selected

item()

Return the item itself (LVITEM instance)

item_data()

Return the item data (dictionary)

rectangle(area='all')

Return the rectangle of the item.

Possible area values:

  • "all" Returns the bounding rectangle of the entire item, including the icon and label.
  • "icon" Returns the bounding rectangle of the icon or small icon.
  • "text" Returns the bounding rectangle of the item text.
  • "select" Returns the union of the “icon” and “text” rectangles, but excludes columns in report view.
select()

Mark the item as selected

The ListView control must be enabled and visible before an Item can be selected otherwise an exception is raised

state()

Return the state of the item

text()

Return the text of the item

uncheck()

Uncheck the ListView item

class pywinauto.controls.common_controls.AnimationWrapper(element_info)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows Animation common control

friendlyclassname = 'Animation'
windowclasses = ['SysAnimate32']
class pywinauto.controls.common_controls.CalendarWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows Calendar common control

calc_min_rectangle(left, top, right, bottom)

Calculates the minimum size that a rectangle needs to be to fit that number of calendars

count()

Get the calendars count

friendlyclassname = 'Calendar'
get_border()

Get the calendar border

get_current_date()

Get the currently selected date

get_first_weekday()

Get is not in current locale and if so first day of the week

get_id()

Get type of calendar

get_month_delta()

Retrieves the scroll rate for a month calendar control

get_month_range(scope_of_range)

Retrieves date information that represents the high and low limits of a month calendar control’s display.

get_today()

Get today date

get_view()

Get the calendar view

has_title = False
hit_test(x, y)

Determines which portion of a month calendar control is at a given point on the screen

place_in_calendar = {'background': <MagicMock name='mock.win32defines.MCSC_BACKGROUND' id='140205010667448'>, 'month_background': <MagicMock name='mock.win32defines.MCSC_MONTHBK' id='140205011112680'>, 'text': <MagicMock name='mock.win32defines.MCSC_TEXT' id='140205011080136'>, 'title_background': <MagicMock name='mock.win32defines.MCSC_TITLEBK' id='140205011100840'>, 'title_text': <MagicMock name='mock.win32defines.MCSC_TITLETEXT' id='140205011178888'>, 'trailing_text': <MagicMock name='mock.win32defines.MCSC_TRAILINGTEXT' id='140205011039848'>}
set_border(border)

Set the calendar border

set_color(place_of_color, red, green, blue)

Set some color in some place of calendar which you specify.

Receive four parameters: - The first parameter may take few variants below: ‘background’, ‘month_background’, ‘text’, ‘title_background’, ‘title_text’, ‘trailing_text’ ; - All other parameters should be integer from 0 to 255.

set_current_date(year, month, day_of_week, day)

Set the currently selected date

set_day_states(month_states)

Sets the day states for all months that are currently visible

set_first_weekday(dayNum)

Set first day of the week

set_id(ID)

Set the calendar type.

Receive only one parameter, which takes variants below: ‘gregorian’, ‘gregorian_us’, ‘japan’, ‘taiwan’, ‘korea’, ‘hijri’, ‘thai’, ‘hebrew’, ‘gregorian_me_french’, ‘gregorian_arabic’, ‘gregorian_english_xlit’, ‘gregorian_french_xlit’, ‘umalqura’

set_month_delta(delta)

Sets the scroll rate for a month calendar control.

set_today(year, month, day)

Set today date

set_view(viewType)

Set the calendar view

windowclasses = ['SysMonthCal32']
class pywinauto.controls.common_controls.ComboBoxExWrapper(element_info)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows ComboBoxEx common control

friendlyclassname = 'ComboBoxEx'
has_title = False
windowclasses = ['ComboBoxEx32']
class pywinauto.controls.common_controls.DateTimePickerWrapper(element_info)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows DateTimePicker common control

GetTime(*args, **kwargs)
SetTime(*args, **kwargs)
friendlyclassname = 'DateTimePicker'
get_time()

Get the currently selected time

has_title = False
set_time(year=0, month=0, day_of_week=0, day=0, hour=0, minute=0, second=0, milliseconds=0)

Set the currently selected time

windowclasses = ['SysDateTimePick32', 'WindowsForms\\d*\\.SysDateTimePick32\\..*']
class pywinauto.controls.common_controls.HeaderWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows ListView Header common control

GetColumnRectangle(*args, **kwargs)
GetColumnText(*args, **kwargs)
ItemCount(*args, **kwargs)
client_rects()

Return all the client rectangles for the header control

friendlyclassname = 'Header'
get_column_rectangle(column_index)

Return the rectangle for the column specified by column_index

get_column_text(column_index)

Return the text for the column specified by column_index

item_count()

Return the number of columns in this header

texts()

Return the texts of the Header control

windowclasses = ['SysHeader32', 'msvb_lib_header']
class pywinauto.controls.common_controls.HotkeyWrapper(element_info)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows Hotkey common control

friendlyclassname = 'Hotkey'
has_title = False
windowclasses = ['msctls_hotkey32']
class pywinauto.controls.common_controls.IPAddressWrapper(element_info)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows IPAddress common control

friendlyclassname = 'IPAddress'
has_title = False
windowclasses = ['SysIPAddress32']
class pywinauto.controls.common_controls.ListViewWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows ListView common control

This class derives from HwndWrapper - so has all the methods o that class also

see hwndwrapper.HwndWrapper

Check(*args, **kwargs)
ColumnCount(*args, **kwargs)
ColumnWidths(*args, **kwargs)
Columns(*args, **kwargs)
Deselect(*args, **kwargs)
GetColumn(*args, **kwargs)
GetHeaderControl(*args, **kwargs)
GetItem(*args, **kwargs)
GetItemRect(*args, **kwargs)
GetSelectedCount(*args, **kwargs)
IsFocused(*args, **kwargs)
IsSelected(*args, **kwargs)
Item(*args, **kwargs)
ItemCount(*args, **kwargs)
Items(*args, **kwargs)
Select(*args, **kwargs)
UnCheck(*args, **kwargs)
check(item)

Check the ListView item

column_count()

Return the number of columns

column_widths()

Return a list of all the column widths

columns()

Get the information on the columns of the ListView

deselect(item)

Mark the item as not selected

The ListView control must be enabled and visible before an Item can be selected otherwise an exception is raised

friendlyclassname = 'ListView'
get_column(col_index)

Get the information for a column of the ListView

get_header_control()

Returns the Header control associated with the ListView

get_item(item_index, subitem_index=0)

Return the item of the list view”

  • item_index Can be either an index of the item or a string with the text of the item you want returned.
  • subitem_index A zero based index of the item you want returned. Defaults to 0.
get_item_rect(item_index)

Return the bounding rectangle of the list view item

get_selected_count()

Return the number of selected items

is_checked(item)

Return whether the ListView item is checked or not

is_focused(item)

Return True if the item has the focus

is_selected(item)

Return True if the item is selected

item(item_index, subitem_index=0)

Return the item of the list view”

  • item_index Can be either an index of the item or a string with the text of the item you want returned.
  • subitem_index A zero based index of the item you want returned. Defaults to 0.
item_count()

The number of items in the ListView

items()

Get all the items in the list view

select(item)

Mark the item as selected

The ListView control must be enabled and visible before an Item can be selected otherwise an exception is raised

texts()

Get the texts for the ListView control

uncheck(item)

Uncheck the ListView item

windowclasses = ['SysListView32', 'WindowsForms\\d*\\.SysListView32\\..*', 'TSysListView', 'ListView.*WndClass']
writable_props

Extend default properties list.

class pywinauto.controls.common_controls.PagerWrapper(element_info)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows Pager common control

GetPosition(*args, **kwargs)
SetPosition(*args, **kwargs)
friendlyclassname = 'Pager'
get_position()

Return the current position of the pager

set_position(pos)

Set the current position of the pager

windowclasses = ['SysPager']
class pywinauto.controls.common_controls.ProgressWrapper(element_info)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows Progress common control

GetPosition(*args, **kwargs)
GetState(*args, **kwargs)
GetStep(*args, **kwargs)
SetPosition(*args, **kwargs)
StepIt(*args, **kwargs)
friendlyclassname = 'Progress'
get_position()

Return the current position of the progress bar

get_state()

Get the state of the progress bar

State will be one of the following constants:
  • PBST_NORMAL
  • PBST_ERROR
  • PBST_PAUSED
get_step()

Get the step size of the progress bar

has_title = False
set_position(pos)

Set the current position of the progress bar

step_it()

Move the progress bar one step size forward

windowclasses = ['msctls_progress', 'msctls_progress32']
class pywinauto.controls.common_controls.ReBarWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows ReBar common control

BandCount(*args, **kwargs)
GetBand(*args, **kwargs)
GetToolTipsControl(*args, **kwargs)
band_count()

Return the number of bands in the control

friendlyclassname = 'ReBar'
get_band(band_index)

Get a band of the ReBar control

get_tool_tips_control()

Return the tooltip control associated with this control

texts()

Return the texts of the Rebar

windowclasses = ['ReBarWindow32']
writable_props

Extend default properties list.

class pywinauto.controls.common_controls.StatusBarWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows Status Bar common control

BorderWidths(*args, **kwargs)
GetPartRect(*args, **kwargs)
GetPartText(*args, **kwargs)
PartCount(*args, **kwargs)
PartRightEdges(*args, **kwargs)
border_widths()

Return the border widths of the StatusBar

A dictionary of the 3 available widths is returned: Horizontal - the horizontal width Vertical - The width above and below the status bar parts Inter - The width between parts of the status bar

client_rects()

Return the client rectangles for the control

friendlyclassname = 'StatusBar'
get_part_rect(part_index)

Return the rectangle of the part specified by part_index

get_part_text(part_index)

Return the text of the part specified by part_index

part_count()

Return the number of parts

part_right_edges()

Return the widths of the parts

texts()

Return the texts for the control

windowclasses = ['msctls_statusbar32', '.*StatusBar', 'WindowsForms\\d*\\.msctls_statusbar32\\..*']
writable_props

Extend default properties list.

class pywinauto.controls.common_controls.TabControlWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows Tab common control

GetSelectedTab(*args, **kwargs)
GetTabRect(*args, **kwargs)
GetTabText(*args, **kwargs)
RowCount(*args, **kwargs)
Select(*args, **kwargs)
TabCount(*args, **kwargs)
client_rects()

Return the client rectangles for the Tab Control

friendlyclassname = 'TabControl'
get_properties()

Return the properties of the TabControl as a Dictionary

get_selected_tab()

Return the index of the selected tab

get_tab_rect(tab_index)

Return the rectangle to the tab specified by tab_index

get_tab_text(tab_index)

Return the text of the tab

row_count()

Return the number of rows of tabs

select(tab)

Select the specified tab on the tab control

tab_count()

Return the number of tabs

texts()

Return the texts of the Tab Control

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

Extend default properties list.

class pywinauto.controls.common_controls.ToolTip(ctrl, tip_index)

Bases: object

Class that Wraps a single tip from a ToolTip control

class pywinauto.controls.common_controls.ToolTipsWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows ToolTips common control (not fully implemented)

GetTip(*args, **kwargs)
GetTipText(*args, **kwargs)
ToolCount(*args, **kwargs)
friendlyclassname = 'ToolTips'
get_tip(tip_index)

Return the particular tooltip

get_tip_text(tip_index)

Return the text of the tooltip

texts()

Return the text of all the tooltips

tool_count()

Return the number of tooltips

windowclasses = ['tooltips_class32', '.*ToolTip', '#32774', 'MS_WINNOTE', 'VBBubble']
class pywinauto.controls.common_controls.ToolbarWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows Toolbar common control

Button(*args, **kwargs)
ButtonCount(*args, **kwargs)
CheckButton(*args, **kwargs)
GetButton(*args, **kwargs)
GetButtonRect(*args, **kwargs)
GetButtonStruct(*args, **kwargs)
GetToolTipsControl(*args, **kwargs)
MenuBarClickInput(*args, **kwargs)
PressButton(*args, **kwargs)
TipTexts(*args, **kwargs)
button(button_identifier, exact=True, by_tooltip=False)

Return the button at index button_index

button_count()

Return the number of buttons on the ToolBar

check_button(button_identifier, make_checked, exact=True)

Find where the button is and click it if it’s unchecked and vice versa

friendlyclassname = 'Toolbar'
get_button(button_index)

Return information on the Toolbar button

get_button_rect(button_index)

Get the rectangle of a button on the toolbar

get_button_struct(button_index)

Return TBBUTTON structure on the Toolbar button

get_tool_tips_control()

Return the tooltip control associated with this control

menu_bar_click_input(path, app)

Select menu bar items by path (experimental!)

The path is specified by a list of items separated by ‘->’ each Item can be the zero based index of the item to return prefaced by # e.g. #1.

Example:
“#1 -> #0”, “#1->#0->#0”
press_button(button_identifier, exact=True)

Find where the button is and click it

texts()

Return the texts of the Toolbar

tip_texts()

Return the tip texts of the Toolbar (without window text)

windowclasses = ['ToolbarWindow32', 'TToolBar', 'WindowsForms\\d*\\.ToolbarWindow32\\..*', 'Afx:ToolBar:.*']
writable_props

Extend default properties list.

class pywinauto.controls.common_controls.TrackbarWrapper(element_info)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows Trackbar common control

friendlyclassname = 'Trackbar'
get_channel_rect()

Get position of the bounding rectangle for a Trackbar

get_line_size()

Get the number of logical positions the trackbar’s slider

get_num_ticks()

Get trackbar num ticks

get_page_size()

Get the number of logical positions for the trackbar’s slider

get_position()

Get trackbar position

get_range_max()

Get max available trackbar value

get_range_min()

Get min available trackbar value

get_sel_end()

Get end of selection

get_sel_start()

Get start of selection

get_tooltips_control()

Get trackbar tooltip

set_line_size(line_size)

Set trackbar line size

set_page_size(page_size)

Set trackbar page size

set_position(pos)

Set trackbar position

set_range_max(range_max)

Set max available trackbar value

set_range_min(range_min)

Set min available trackbar value

set_sel(sel_start, sel_end)

Set start and end of selection

windowclasses = ['msctls_trackbar']
class pywinauto.controls.common_controls.TreeViewWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows TreeView common control

EnsureVisible(*args, **kwargs)
GetItem(*args, **kwargs)
IsSelected(*args, **kwargs)
Item(*args, **kwargs)
ItemCount(*args, **kwargs)
PrintItems(*args, **kwargs)
Root(*args, **kwargs)
Roots(*args, **kwargs)
Select(*args, **kwargs)
ensure_visible(path)

Make sure that the TreeView item is visible

friendlyclassname = 'TreeView'
get_item(path, exact=False)

Read the TreeView item

  • path the 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.
get_properties()

Get the properties for the control as a dictionary

is_selected(path)

Return True if the item is selected

item(path, exact=False)

Read the TreeView item

  • path the 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.
item_count()

Return the count of the items in the treeview

print_items()

Print all items with line indents

roots()

Get root items of the control

select(path)

Select the treeview item

texts()

Return all the text for the tree view

tree_root()

Return the root element of the tree view

windowclasses = ['SysTreeView32', 'WindowsForms\\d*\\.SysTreeView32\\..*', 'TTreeView', 'TreeList.TreeListCtrl']
writable_props

Extend default properties list.

class pywinauto.controls.common_controls.UpDownWrapper(hwnd)

Bases: pywinauto.controls.hwndwrapper.HwndWrapper

Class that wraps Windows UpDown common control

Decrement(*args, **kwargs)
GetBase(*args, **kwargs)
GetBuddyControl(*args, **kwargs)
GetRange(*args, **kwargs)
GetValue(*args, **kwargs)
Increment(*args, **kwargs)
SetBase(*args, **kwargs)
SetValue(*args, **kwargs)
decrement()

Decrement the number in the UpDown control by one

friendlyclassname = 'UpDown'
get_base()

Get the base the UpDown control (either 10 or 16)

get_buddy_control()

Get the buddy control of the updown control

get_range()

Return the lower, upper range of the up down control

get_value()

Get the current value of the UpDown control

increment()

Increment the number in the UpDown control by one

set_base(base_value)

Get the base the UpDown control (either 10 or 16)

set_value(new_pos)

Set the value of the of the UpDown control to some integer value

windowclasses = ['msctls_updown32', 'msctls_updown']