Platforms to show: All Mac Windows Linux Cross-Platform

UIAutomationMBS class   New in 26.2

Type Topic Plugin Version macOS Windows Linux iOS Targets
class UIAutomation MBS WinFrameworks Plugin 26.2 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Exposes methods that enable Microsoft UI Automation client applications to discover, access, and filter UI Automation elements.
Example
Var UIAutomation As New UIAutomationMBS
Var appElement As UIAutomationElementMBS = UIAutomation.RootElement

// list windows to console to find names
var ea as UIAutomationElementArrayMBS = appElement.FindAll(UIAutomationMBS.TreeScopeChildren, UIAutomation.CreateTrueCondition)
for each e as UIAutomationElementMBS in ea.Elements
System.DebugLog e.CurrentName
next

// put in exact name of window!
Var value1 As Variant = "Hello.txt – Notepad"
Var cond1 As UIAutomationPropertyConditionMBS = UIAutomation.CreatePropertyCondition(UIAutomationElementMBS.PropertyIdName, value1)
Var notepad As UIAutomationElementMBS = appElement.FindFirst(UIAutomationMBS.TreeScopeSubtree, cond1)

If notepad <> Nil Then
MessageBox("Found Notepad window!")

var ControlTypeDocument as int32 = UIAutomationElementMBS.ControlTypeDocument
Var value2 As Variant = ControlTypeDocument // must be int32
Var cond2 As UIAutomationPropertyConditionMBS = UIAutomation.CreatePropertyCondition(UIAutomationElementMBS.PropertyIdControlType, value2)
Var docControl As UIAutomationElementMBS = notepad.FindFirst(UIAutomationMBS.TreeScopeSubtree, cond2)

If docControl <> Nil Then
Var textPattern As UIAutomationTextPatternMBS = docControl.CurrentPattern(docControl.PatternIdText)
If textPattern <> Nil Then
// shows text from notepad window
MessageBox(textPattern.DocumentRange.Text)
End If
Else
MessageBox("Document control not found.")
End If
else
MessageBox("Notepad window not found!")
End If

UI Automation exposes every element of the UI Automation as an object represented by the IUIAutomation interface. The members of this interface are not specific to a particular element.

All methods in the UIAutomation* classes raise an UIAutomationExceptionMBS in case of an error.

For the properties there are often cached and current values.
With current value, you send a request to the host application to query the value. With cached values you have the chance, that values could come from a cache if they have been recently read. This is increases performance.

We route events to main thread, if they are called on a different thread. Please keep the main thread responsive for event processing.

This class has no sub classes.

Blog Entries

Some methods using this class:

Some examples using this class:

Some related classes:


The items on this page are in the following plugins: MBS WinFrameworks Plugin.


UIAutomationLegacyIAccessiblePatternMBS   -   UIAutomationMultipleViewPatternMBS


The biggest plugin in space...