Condition Factory
flaui.core.condition_factory.ConditionFactory
Bases: BaseModel
ConditionFactory wraps a ConditionFactory object from FlaUI.Core.Conditions module. This class provides methods to create PropertyConditions based on automation id, control type, class name, name, and text.
by_automation_id(automation_id, condition_flags_property_condition_flags=PropertyConditionFlags.None_)
Creates a condition to search by an automation id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
automation_id
|
str
|
Automation ID |
required |
condition_flags_property_condition_flags
|
PropertyConditionFlags
|
Contains values used in creating property conditions, defaults to PropertyConditionFlags.none |
None_
|
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
Property Condition |
Source code in flaui/core/condition_factory.py
by_class_name(class_name, condition_flags_property_condition_flags=PropertyConditionFlags.None_)
Creates a condition to search by a class name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
class_name
|
Union[str, KnownClassNames]
|
Class Name |
required |
condition_flags_property_condition_flags
|
PropertyConditionFlags
|
Contains values used in creating property conditions, defaults to PropertyConditionFlags.none |
None_
|
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
Property Condition |
Source code in flaui/core/condition_factory.py
by_control_type(control_type)
Creates a condition to search by a ControlType.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control_type
|
ControlType
|
Types of controls in Microsoft UI Automation. |
required |
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
Property Condition |
Source code in flaui/core/condition_factory.py
by_framework_id(framework_id, condition_flags_property_condition_flags=PropertyConditionFlags.None_)
Creates a condition to search by a Framework Id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
framework_id
|
str
|
Framework ID |
required |
condition_flags_property_condition_flags
|
PropertyConditionFlags
|
Contains values used in creating property conditions, defaults to PropertyConditionFlags.none |
None_
|
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
Property Condition |
Source code in flaui/core/condition_factory.py
by_framework_type(framework_type)
Creates a condition to search by a Framework Type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
framework_type
|
FrameworkType
|
Framework Type |
required |
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
Property Condition |
Source code in flaui/core/condition_factory.py
by_help_text(help_text, condition_flags_property_condition_flags=PropertyConditionFlags.None_)
Creates a condition to search by a help text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
help_text
|
str
|
Help text |
required |
condition_flags_property_condition_flags
|
PropertyConditionFlags
|
Contains values used in creating property conditions, defaults to PropertyConditionFlags.none |
None_
|
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
Property Condition |
Source code in flaui/core/condition_factory.py
by_localized_control_type(localized_control_type, condition_flags_property_condition_flags=PropertyConditionFlags.None_)
Creates a condition to search by a localized control type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
localized_control_type
|
str
|
Localized Control Type |
required |
condition_flags_property_condition_flags
|
PropertyConditionFlags
|
Contains values used in creating property conditions, defaults to PropertyConditionFlags.none |
None_
|
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
Property Condition |
Source code in flaui/core/condition_factory.py
by_name(name, condition_flags_property_condition_flags=PropertyConditionFlags.None_)
Creates a condition to search by a name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name |
required |
condition_flags_property_condition_flags
|
PropertyConditionFlags
|
Contains values used in creating property conditions, defaults to PropertyConditionFlags.none |
None_
|
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
Property Condition |
Source code in flaui/core/condition_factory.py
by_process_id(process_id)
Creates a condition to search by a process id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_id
|
int
|
Process ID |
required |
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
Property Condition |
Source code in flaui/core/condition_factory.py
by_text(text, condition_flags_property_condition_flags=PropertyConditionFlags.None_)
Creates a condition to search by a text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text value |
required |
condition_flags_property_condition_flags
|
PropertyConditionFlags
|
Contains values used in creating property conditions, defaults to PropertyConditionFlags.none |
None_
|
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
Property Condition |
Source code in flaui/core/condition_factory.py
by_value(value, condition_flags_property_condition_flags=PropertyConditionFlags.None_)
Creates a condition to search by a value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Value |
required |
condition_flags_property_condition_flags
|
PropertyConditionFlags
|
Contains values used in creating property conditions, defaults to PropertyConditionFlags.none |
None_
|
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
Property Condition |
Source code in flaui/core/condition_factory.py
false_condition()
staticmethod
Return a condition that matches no element (C# FalseCondition.Default).
Useful as the neutral start when building a condition up with |.
Returns:
| Type | Description |
|---|---|
FalseCondition
|
A :class: |
Source code in flaui/core/condition_factory.py
grid()
horizontal_scroll_bar()
menu()
true_condition()
staticmethod
Return a condition that matches every element (C# TrueCondition.Default).
Useful as the neutral start when building a condition up with &.
Returns:
| Type | Description |
|---|---|
TrueCondition
|
A :class: |
Source code in flaui/core/condition_factory.py
vertical_scroll_bar()
Conditions
Every condition supports &, | and ~ (or and_(), or_(), not_()). See
Combining conditions.
flaui.core.condition_factory.ConditionBase
Bases: BaseModel
Base for every search condition; mirrors FlaUI.Core.Conditions.ConditionBase.
Combine conditions with the methods or the operators::
ok_button = cf.by_name("OK") & cf.by_control_type(ControlType.Button)
either = cf.by_automation_id("a") | cf.by_automation_id("b")
not_ok = ~cf.by_name("OK")
And(new_condition)
Combine with "and"; alias of :meth:and_ kept for backward compatibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_condition
|
ConditionLike
|
Condition to combine with; a wrapper or a raw C# condition. |
required |
Returns:
| Type | Description |
|---|---|
AndCondition
|
An :class: |
Source code in flaui/core/condition_factory.py
Equals(value)
Compare this condition to another (C# Equals).
C# compares property conditions by property, value and flags, but compares And/Or/
Not conditions by reference. To compare two combined conditions by content, compare
str(a) == str(b).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ConditionLike
|
Condition to compare; a wrapper or a raw C# condition. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True when both conditions are equal. |
Source code in flaui/core/condition_factory.py
Not(new_condition=None)
Negate; kept for backward compatibility, prefer :meth:not_ or ~.
Without an argument this matches C# ConditionBase.Not() and negates this condition.
With an argument it keeps the historical Python meaning, self AND NOT new_condition,
which is self & ~new_condition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_condition
|
Optional[ConditionLike]
|
Optional condition to negate and combine with this one. |
None
|
Returns:
| Type | Description |
|---|---|
Union[NotCondition, AndCondition]
|
A :class: |
Source code in flaui/core/condition_factory.py
Or(new_condition)
Combine with "or"; alias of :meth:or_ kept for backward compatibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_condition
|
ConditionLike
|
Condition to combine with; a wrapper or a raw C# condition. |
required |
Returns:
| Type | Description |
|---|---|
OrCondition
|
An :class: |
Source code in flaui/core/condition_factory.py
ToString()
Render the condition as text (C# ToString).
Returns:
| Type | Description |
|---|---|
str
|
Text form of the condition, e.g. |
Source code in flaui/core/condition_factory.py
__and__(other)
__invert__()
__or__(other)
__rand__(other)
__ror__(other)
__str__()
and_(new_condition)
Combine this condition with another using "and" (C# ConditionBase.And).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_condition
|
ConditionLike
|
Condition to combine with; a wrapper or a raw C# condition. |
required |
Returns:
| Type | Description |
|---|---|
AndCondition
|
An :class: |
Source code in flaui/core/condition_factory.py
not_()
Negate this condition (C# ConditionBase.Not).
Returns:
| Type | Description |
|---|---|
NotCondition
|
A :class: |
Source code in flaui/core/condition_factory.py
or_(new_condition)
Combine this condition with another using "or" (C# ConditionBase.Or).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_condition
|
ConditionLike
|
Condition to combine with; a wrapper or a raw C# condition. |
required |
Returns:
| Type | Description |
|---|---|
OrCondition
|
An :class: |
Source code in flaui/core/condition_factory.py
flaui.core.condition_factory.PropertyCondition
Bases: ConditionBase
A condition that checks one property; mirrors FlaUI.Core.Conditions.PropertyCondition.
For backward compatibility every other condition wrapper derives from this class, so APIs
typed as taking a PropertyCondition accept any condition. Property, Value and
PropertyConditionFlags are only meaningful on a real property condition.
Property
property
The property that should be checked.
Returns:
| Type | Description |
|---|---|
Any
|
Property |
PropertyConditionFlags
property
Optional flags that are used when checking the property.
Returns:
| Type | Description |
|---|---|
'PropertyConditionFlags'
|
Property Condition Flags |
Value
property
The value that is used for checking.
Returns:
| Type | Description |
|---|---|
Union[str, Any]
|
Value |
flaui.core.condition_factory.AndCondition
Bases: JunctionConditionBase
A condition that matches when all its conditions match; mirrors AndCondition.
flaui.core.condition_factory.OrCondition
Bases: JunctionConditionBase
A condition that matches when any of its conditions match; mirrors OrCondition.
flaui.core.condition_factory.JunctionConditionBase
Bases: PropertyCondition
Base for conditions that join several conditions; mirrors JunctionConditionBase.
child_count
property
Return how many conditions this junction joins.
Returns:
| Type | Description |
|---|---|
int
|
Number of joined conditions. |
conditions
property
Return the joined conditions.
Returns:
| Type | Description |
|---|---|
List[PropertyCondition]
|
The conditions, each wrapped in its matching Python class. |
flaui.core.condition_factory.NotCondition
Bases: PropertyCondition
A condition that negates another; mirrors FlaUI.Core.Conditions.NotCondition.
condition
property
Return the negated condition.
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
The inner condition, wrapped in its matching Python class. |
flaui.core.condition_factory.BoolCondition
Bases: PropertyCondition
A condition that is always true or always false; mirrors FlaUI.Core.Conditions.BoolCondition.
boolean_value
property
Return the fixed result of this condition.
Returns:
| Type | Description |
|---|---|
bool
|
True for a :class: |
flaui.core.condition_factory.TrueCondition
Bases: BoolCondition
A condition that matches every element; mirrors FlaUI.Core.Conditions.TrueCondition.
default()
classmethod
Return the shared true condition (C# TrueCondition.Default).
Returns:
| Type | Description |
|---|---|
TrueCondition
|
A :class: |
Source code in flaui/core/condition_factory.py
flaui.core.condition_factory.FalseCondition
Bases: BoolCondition
A condition that matches no element; mirrors FlaUI.Core.Conditions.FalseCondition.
default()
classmethod
Return the shared false condition (C# FalseCondition.Default).
Returns:
| Type | Description |
|---|---|
FalseCondition
|
A :class: |
Source code in flaui/core/condition_factory.py
flaui.core.condition_factory.wrap_condition(cs_condition)
Wrap a raw C# condition in the matching Python class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cs_condition
|
Any
|
A C# |
required |
Returns:
| Type | Description |
|---|---|
PropertyCondition
|
A :class: |