Automation
flaui.modules.automation.Automation(ui_automation_type, timeout=1000)
UIAutomation constructed wrapper for FlaUI usage.
FlaUI is written entirely on C# .Net, using it directly inside an IDE within a Python project would be painful since intellisense does not pick up the methods/typing hints.
This class is designed to overcome those challenges by providing Python compatible workstream.
Attributes: ui_automation_type (UIAutomationTypes): The type of UI automation to use (UIA2 or UIA3). timeout (int): The timeout value in milliseconds. automation_base (AutomationBase): Python facade for the C# automation (preferred for typed APIs). cs_automation (Any): Raw C# UIA2Automation or UIA3Automation (interop and backward compatibility). cf (ConditionFactory): The condition factory instance. tree_walker (RawViewWalker): The tree walker instance. application (Application): The application instance.
Initializes the UIAutomation wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ui_automation_type
|
UIAutomationTypes
|
The type of UI automation to use (UIA2 or UIA3). |
required |
timeout
|
int
|
The timeout value in milliseconds. |
1000
|
Source code in flaui/modules/automation.py
__enter__()
Enter the runtime context and return the automation instance.
Enables with Automation(UIAutomationTypes.UIA3) as auto: usage. The managed application
is closed and the underlying C# automation is disposed automatically on exit.
Returns:
| Type | Description |
|---|---|
Automation
|
This automation instance. |
Source code in flaui/modules/automation.py
__exit__(exc_type, exc_value, traceback)
Exit the runtime context, closing the application and disposing the automation.
Never raises — cleanup failures are swallowed so they cannot mask an exception raised inside
the with block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc_type
|
Any
|
The exception type raised in the context, if any. |
required |
exc_value
|
Any
|
The exception instance raised in the context, if any. |
required |
traceback
|
Any
|
The traceback for the exception, if any. |
required |