This project is read-only.
For our experiments we will use calc.exe put in the Mortgage mode:
Start-Process calc -PassThru | Get-UIAWindow | Get-UIAMenuItem -Name View | Invoke-UIAMenuItemExpand | Get-UIAMenuItem -Name Worksheets | Move-UIACursor -X 3 -Y 3 | Get-UIAMenuItem -Name Mortgage | Invoke-UIAMenuItemClick;

Getting the full list of items

The only things you need to know here is that items in combo box are of type ListItem:
Get-UIAWindow -pn calc | Get-UIAComboBox | Get-UIAListItem | Read-UIAControlName;
The Read-UIAControlName cmdlet is here for readability only: if you need to get AutomationElements of items, yor code would be:
Get-UIAWindow -pn calc | Get-UIAComboBox | Get-UIAListItem;

Getting the selected item

Get-UIAWindow -pn calc | Get-UIAComboBox | Get-UIAComboBoxSelection | Read-UIAControlName;

Selecting an item

To select an item in combo box, we first need to get the item we want to select and, second, apply SelectItemPattern to the item. SelectItemPattern requires the name, so that we need to use the name twice:
Get-UIAWindow -pn calc | Get-UIAComboBox | Get-UIAListItem -Name term* | Invoke-UIAListItemSelectItem -ItemName term*

Tags: ControlType.Window, ControlType.MenuItem, ControlType.ComboBox, InvokePattern, ExpandCollapsePattern, move cursor, SelectionPattern, ControlType.ListItem, AutomationElement, SelectItemPattern

Last edited Jan 8, 2013 at 4:32 PM by xinliu, version 8


No comments yet.