Open mikahanninen opened 2 years ago
Add possibility to identify elements based on their properties like currently selected element in the list of elements.
_There doesn't seem to be a solution without using the underlying UIAutomation library by using the item field of the WindowsElement object, like so: select_pattern = list_control_elem.item.GetSelectionPattern() return selectpattern.GetSelection()[0].Name This is a bad solution since I'm skipping a layer and creating an unwanted dependency. RPA.Windows should provide at least wrappers for all UI functions. Same issue occurs with other patterns like GetTogglePattern().
Here's a list of the patterns we're currently using:
To check if an item is selected:
select_pattern = control.item.GetSelectionItemPattern() return select_pattern.IsSelected
To get the select item from list or combobox
select_pattern = list_control_elem.item.GetSelectionPattern() return select_pattern.GetSelection()[0].Name
To get the state of a toggle:
switch = switch_control.item.GetTogglePattern() return switch.ToggleState == 1 if switch_state else switch.ToggleState == 0
To set a slider value:
pattern = control.item.GetRangeValuePattern() pattern.SetValue(set_value)
We're also using the table pattern:
laser_pattern = laser_table.item.GetTablePattern() col_headers = laser_pattern.GetColumnHeaders()
Additionally to those mentioned, in my project, I have found myself using properties like item.IsEnabled
and item.HasKeyboardFocus
. However, item.GetSelectionPattern().GetSelection()[0].Name
is by far the one I use most often.
At the moment
WindowsElement
contains propertyitem
which represents underlyingControl
object of the uiautomation package.Property contains details which could be exposed as keywords and/or listed as properties in the
WindowsElement
object.