🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# pywinauto.controls.uia_controls Wrap various UIA windows controls [TOC] ## *class* `pywinauto.controls.uia_controls.ButtonWrapper`(*elem*) Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "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`()[¶](#pywinauto.controls.uia_controls.ButtonWrapper.is_dialog "Permalink to this definition") > > Buttons are never dialogs so return False > > `toggle`()[¶](#pywinauto.controls.uia_controls.ButtonWrapper.toggle "Permalink to this definition") > > 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](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`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") > > Wrap a UIA CoboBox control > > `collapse`()[¶](#pywinauto.controls.uia_controls.ComboBoxWrapper.collapse "Permalink to this definition") > > `expand`()[¶](#pywinauto.controls.uia_controls.ComboBoxWrapper.expand "Permalink to this definition") > > `get_expand_state`()[¶](#pywinauto.controls.uia_controls.ComboBoxWrapper.get_expand_state "Permalink to this definition") > > `is_editable`()[¶](#pywinauto.controls.uia_controls.ComboBoxWrapper.is_editable "Permalink to this definition") > > `item_count`()[¶](#pywinauto.controls.uia_controls.ComboBoxWrapper.item_count "Permalink to this definition") > > Return the number of items in the combobox > > The interface is kept mostly for a backward compatibility with the native ComboBox interface > > `select`(*item*)[¶](#pywinauto.controls.uia_controls.ComboBoxWrapper.select "Permalink to this definition") > > 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`()[¶](#pywinauto.controls.uia_controls.ComboBoxWrapper.selected_index "Permalink to this definition") > > Return the selected index > > `selected_text`()[¶](#pywinauto.controls.uia_controls.ComboBoxWrapper.selected_text "Permalink to this definition") > > 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`()[¶](#pywinauto.controls.uia_controls.ComboBoxWrapper.texts "Permalink to this definition") > > Return the text of the items in the combobox > ## *class* `pywinauto.controls.uia_controls.EditWrapper(elem)` > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") > > Wrap an UIA-compatible Edit control > > `get_line`(*line\_index*)[¶](#pywinauto.controls.uia_controls.EditWrapper.get_line "Permalink to this definition") > > Return the line specified > > `get_value`()[¶](#pywinauto.controls.uia_controls.EditWrapper.get_value "Permalink to this definition") > > Return the current value of the element > > `has_title` *= False*[¶](#pywinauto.controls.uia_controls.EditWrapper.has_title "Permalink to this definition") > > `is_editable`()[¶](#pywinauto.controls.uia_controls.EditWrapper.is_editable "Permalink to this definition") > > Return the edit possibility of the element > > `line_count`()[¶](#pywinauto.controls.uia_controls.EditWrapper.line_count "Permalink to this definition") > > Return how many lines there are in the Edit > > `line_length`(*line\_index*)[¶](#pywinauto.controls.uia_controls.EditWrapper.line_length "Permalink to this definition") > > Return how many characters there are in the line > > `select`(*start=0*, *end=None*)[¶](#pywinauto.controls.uia_controls.EditWrapper.select "Permalink to this definition") > > Set the edit selection of the edit control > > `selection_indices`()[¶](#pywinauto.controls.uia_controls.EditWrapper.selection_indices "Permalink to this definition") > > The start and end indices of the current selection > > `set_edit_text`(*text*, *pos\_start=None*, *pos\_end=None*)[¶](#pywinauto.controls.uia_controls.EditWrapper.set_edit_text "Permalink to this definition") > > Set the text of the edit control > > `set_text`(*text*, *pos\_start=None*, *pos\_end=None*)[¶](#pywinauto.controls.uia_controls.EditWrapper.set_text "Permalink to this definition") > > Set the text of the edit control > > `set_window_text`(*text*, *append=False*)[¶](#pywinauto.controls.uia_controls.EditWrapper.set_window_text "Permalink to this definition") > > 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`()[¶](#pywinauto.controls.uia_controls.EditWrapper.text_block "Permalink to this definition") > > Get the text of the edit control > > `texts`()[¶](#pywinauto.controls.uia_controls.EditWrapper.texts "Permalink to this definition") > > Get the text of the edit control > > `writable_props`[¶](#pywinauto.controls.uia_controls.EditWrapper.writable_props "Permalink to this definition") > > Extend default properties list. > ## *class* `pywinauto.controls.uia_controls.HeaderItemWrapper(elem)` > > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") > > Wrap an UIA-compatible Header Item control > ## *class* `pywinauto.controls.uia_controls.HeaderWrapper(elem)` > > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") > > Wrap an UIA-compatible Header control > ## *class* `pywinauto.controls.uia_controls.ListItemWrapper(elem, container=None)` > > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") > > Wrap an UIA-compatible ListViewItem control > > `is_checked`()[¶](#pywinauto.controls.uia_controls.ListItemWrapper.is_checked "Permalink to this definition") > > Return True if the ListItem is checked > > Only items supporting Toggle pattern should answer. Raise NoPatternInterfaceError if the pattern is not supported > > `texts`()[¶](#pywinauto.controls.uia_controls.ListItemWrapper.texts "Permalink to this definition") > > Return a list of item texts > ## *class* `pywinauto.controls.uia_controls.ListViewWrapper(elem)` > > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") > > Wrap an UIA-compatible ListView control > > `cell`(*row*, *column*)[¶](#pywinauto.controls.uia_controls.ListViewWrapper.cell "Permalink to this definition") > > 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`()[¶](#pywinauto.controls.uia_controls.ListViewWrapper.cells "Permalink to this definition") > > Return list of list of cells for any type of contol > > `column_count`()[¶](#pywinauto.controls.uia_controls.ListViewWrapper.column_count "Permalink to this definition") > > Return the number of columns > > `columns`()[¶](#pywinauto.controls.uia_controls.ListViewWrapper.columns "Permalink to this definition") > > Get the information on the columns of the ListView > > `get_column`(*col\_index*)[¶](#pywinauto.controls.uia_controls.ListViewWrapper.get_column "Permalink to this definition") > > Get the information for a column of the ListView > > `get_header_control`()[¶](#pywinauto.controls.uia_controls.ListViewWrapper.get_header_control "Permalink to this definition") > > Return Header control associated with the ListView > > `get_header_controls`()[¶](#pywinauto.controls.uia_controls.ListViewWrapper.get_header_controls "Permalink to this definition") > > Return Header controls associated with the Table > > `get_item`(*row*)[¶](#pywinauto.controls.uia_controls.ListViewWrapper.get_item "Permalink to this definition") > > 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*)[¶](#pywinauto.controls.uia_controls.ListViewWrapper.get_item_rect "Permalink to this definition") > > 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`()[¶](#pywinauto.controls.uia_controls.ListViewWrapper.get_items "Permalink to this definition") > > Return all items of the ListView control > > `get_selected_count`()[¶](#pywinauto.controls.uia_controls.ListViewWrapper.get_selected_count "Permalink to this definition") > > 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*)[¶](#pywinauto.controls.uia_controls.ListViewWrapper.item "Permalink to this definition") > > 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`()[¶](#pywinauto.controls.uia_controls.ListViewWrapper.item_count "Permalink to this definition") > > A number of items in the ListView > > `items`()[¶](#pywinauto.controls.uia_controls.ListViewWrapper.items "Permalink to this definition") > > Return all items of the ListView control > > `texts`()[¶](#pywinauto.controls.uia_controls.ListViewWrapper.texts "Permalink to this definition") > > Return a list of item texts > > `writable_props`[¶](#pywinauto.controls.uia_controls.ListViewWrapper.writable_props "Permalink to this definition") > > Extend default properties list. > ## *class* `pywinauto.controls.uia_controls.MenuItemWrapper(elem)` > > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") > > Wrap an UIA-compatible MenuItem control > > `items`()[¶](#pywinauto.controls.uia_controls.MenuItemWrapper.items "Permalink to this definition") > > Find all items of the menu item > > `select`()[¶](#pywinauto.controls.uia_controls.MenuItemWrapper.select "Permalink to this definition") > > Apply Select pattern > ## *class* `pywinauto.controls.uia_controls.MenuWrapper(elem)` > > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") > > Wrap an UIA-compatible MenuBar or Menu control > > `item_by_index`(*idx*)[¶](#pywinauto.controls.uia_controls.MenuWrapper.item_by_index "Permalink to this definition") > > Find a menu item specified by the index > > `item_by_path`(*path*, *exact=False*)[¶](#pywinauto.controls.uia_controls.MenuWrapper.item_by_path "Permalink to this definition") > > Find a menu item specified by the path > > The full path syntax is specified in: [`controls.menuwrapper.Menu.get_menu_path()`](pywinauto.controls.menuwrapper.html#pywinauto.controls.menuwrapper.Menu.get_menu_path "pywinauto.controls.menuwrapper.Menu.get_menu_path") > > Note: $ - specifier is not supported > > `items`()[¶](#pywinauto.controls.uia_controls.MenuWrapper.items "Permalink to this definition") > > Find all menu items > ## *class* `pywinauto.controls.uia_controls.SliderWrapper(elem)` > > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") > > Wrap an UIA-compatible Slider control > > `has_title` *= False*[¶](#pywinauto.controls.uia_controls.SliderWrapper.has_title "Permalink to this definition") > > `large_change`()[¶](#pywinauto.controls.uia_controls.SliderWrapper.large_change "Permalink to this definition") > > 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`()[¶](#pywinauto.controls.uia_controls.SliderWrapper.max_value "Permalink to this definition") > > Get the maximum value of the Slider > > `min_value`()[¶](#pywinauto.controls.uia_controls.SliderWrapper.min_value "Permalink to this definition") > > Get the minimum value of the Slider > > `set_value`(*value*)[¶](#pywinauto.controls.uia_controls.SliderWrapper.set_value "Permalink to this definition") > > Set position of slider’s thumb > > `small_change`()[¶](#pywinauto.controls.uia_controls.SliderWrapper.small_change "Permalink to this definition") > > 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`()[¶](#pywinauto.controls.uia_controls.SliderWrapper.value "Permalink to this definition") > > Get a current position of slider’s thumb > ## *class* `pywinauto.controls.uia_controls.StaticWrapper(elem)` > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") 包装UIA兼容的文本控件 > `can_be_label` *= True* ## *class* `pywinauto.controls.uia_controls.TabControlWrapper(elem)` > > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") > > Wrap an UIA-compatible Tab control > > `get_selected_tab`()[¶](#pywinauto.controls.uia_controls.TabControlWrapper.get_selected_tab "Permalink to this definition") > > Return an index of a selected tab > > `select`(*item*)[¶](#pywinauto.controls.uia_controls.TabControlWrapper.select "Permalink to this definition") > > Select a tab by index or by name > > `tab_count`()[¶](#pywinauto.controls.uia_controls.TabControlWrapper.tab_count "Permalink to this definition") > > Return a number of tabs > > `texts`()[¶](#pywinauto.controls.uia_controls.TabControlWrapper.texts "Permalink to this definition") > > Tabs texts > ## *class* `pywinauto.controls.uia_controls.ToolbarWrapper(elem)` > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "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*)[¶](#pywinauto.controls.uia_controls.ToolbarWrapper.button "Permalink to this definition") > > 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`()[¶](#pywinauto.controls.uia_controls.ToolbarWrapper.button_count "Permalink to this definition") > > Return a number of buttons on the ToolBar > > `buttons`()[¶](#pywinauto.controls.uia_controls.ToolbarWrapper.buttons "Permalink to this definition") > > Return all available buttons > > `check_button`(*button\_identifier*, *make\_checked*, *exact=True*)[¶](#pywinauto.controls.uia_controls.ToolbarWrapper.check_button "Permalink to this definition") > > 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`()[¶](#pywinauto.controls.uia_controls.ToolbarWrapper.texts "Permalink to this definition") > > Return texts of the Toolbar > > `writable_props`[¶](#pywinauto.controls.uia_controls.ToolbarWrapper.writable_props "Permalink to this definition") > > Extend default properties list. > ## *class* `pywinauto.controls.uia_controls.TooltipWrapper(elem)` > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") > > Wrap an UIA-compatible Tooltip control > ## *class* `pywinauto.controls.uia_controls.TreeItemWrapper(elem)` > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "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`()[¶](#pywinauto.controls.uia_controls.TreeItemWrapper.ensure_visible "Permalink to this definition") > > Make sure that the TreeView item is visible > > `get_child`(*child\_spec*, *exact=False*)[¶](#pywinauto.controls.uia_controls.TreeItemWrapper.get_child "Permalink to this definition") > > 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`()[¶](#pywinauto.controls.uia_controls.TreeItemWrapper.is_checked "Permalink to this definition") > > Return True if the TreeItem is checked > > Only items supporting Toggle pattern should answer. Raise NoPatternInterfaceError if the pattern is not supported > > `sub_elements`()[¶](#pywinauto.controls.uia_controls.TreeItemWrapper.sub_elements "Permalink to this definition") > > Return a list of all visible sub-items of this control > ## *class* `pywinauto.controls.uia_controls.TreeViewWrapper(*elem*)` > > Bases: [`pywinauto.controls.uiawrapper.UIAWrapper`](pywinauto.controls.uiawrapper.html#pywinauto.controls.uiawrapper.UIAWrapper "pywinauto.controls.uiawrapper.UIAWrapper") > > Wrap an UIA-compatible Tree control > > `get_item`(*path*, *exact=False*)[¶](#pywinauto.controls.uia_controls.TreeViewWrapper.get_item "Permalink to this definition") > > 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`()[¶](#pywinauto.controls.uia_controls.TreeViewWrapper.item_count "Permalink to this definition") > > Return a number of items in TreeView > > `print_items`()[¶](#pywinauto.controls.uia_controls.TreeViewWrapper.print_items "Permalink to this definition") > > Print all items with line indents > > `roots`()[¶](#pywinauto.controls.uia_controls.TreeViewWrapper.roots "Permalink to this definition") > > Return root elements of TreeView > > `writable_props`[¶](#pywinauto.controls.uia_controls.TreeViewWrapper.writable_props "Permalink to this definition") > > Extend default properties list.