Skip to content

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
def by_automation_id(
    self,
    automation_id: str,
    condition_flags_property_condition_flags: PropertyConditionFlags = PropertyConditionFlags.None_,
) -> PropertyCondition:
    """Creates a condition to search by an automation id.

    :param automation_id: Automation ID
    :param condition_flags_property_condition_flags: Contains values used in creating property conditions, defaults to PropertyConditionFlags.none
    :return: Property Condition
    """
    return PropertyCondition(
        cs_condition=self.raw_cf.ByAutomationId(automation_id, condition_flags_property_condition_flags.value)
    )

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
def by_class_name(
    self,
    class_name: Union[str, KnownClassNames],
    condition_flags_property_condition_flags: PropertyConditionFlags = PropertyConditionFlags.None_,
) -> PropertyCondition:
    """Creates a condition to search by a class name.

    :param class_name: Class Name
    :param condition_flags_property_condition_flags: Contains values used in creating property conditions, defaults to PropertyConditionFlags.none
    :return: Property Condition
    """
    return PropertyCondition(
        cs_condition=self.raw_cf.ByClassName(
            class_name if isinstance(class_name, str) else class_name.value,
            condition_flags_property_condition_flags.value,
        )
    )

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
def by_control_type(self, control_type: ControlType) -> PropertyCondition:
    """Creates a condition to search by a ControlType.

    :param control_type: Types of controls in Microsoft UI Automation.
    :return: Property Condition
    """
    return PropertyCondition(cs_condition=self.raw_cf.ByControlType(control_type.value))

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
def by_framework_id(
    self,
    framework_id: str,
    condition_flags_property_condition_flags: PropertyConditionFlags = PropertyConditionFlags.None_,
) -> PropertyCondition:
    """Creates a condition to search by a Framework Id.

    :param framework_id: Framework ID
    :param condition_flags_property_condition_flags: Contains values used in creating property conditions, defaults to PropertyConditionFlags.none
    :return: Property Condition
    """
    return PropertyCondition(
        cs_condition=self.raw_cf.ByFrameworkId(framework_id, condition_flags_property_condition_flags.value)
    )

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
def by_framework_type(self, framework_type: FrameworkType) -> PropertyCondition:
    """Creates a condition to search by a Framework Type.

    :param framework_type: Framework Type
    :return: Property Condition
    """
    return PropertyCondition(cs_condition=self.raw_cf.ByFrameworkType(framework_type.value))

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
def by_help_text(
    self,
    help_text: str,
    condition_flags_property_condition_flags: PropertyConditionFlags = PropertyConditionFlags.None_,
) -> PropertyCondition:
    """Creates a condition to search by a help text.

    :param help_text: Help text
    :param condition_flags_property_condition_flags: Contains values used in creating property conditions, defaults to PropertyConditionFlags.none
    :return: Property Condition
    """
    return PropertyCondition(
        cs_condition=self.raw_cf.ByHelpText(help_text, condition_flags_property_condition_flags.value)
    )

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
def by_localized_control_type(
    self,
    localized_control_type: str,
    condition_flags_property_condition_flags: PropertyConditionFlags = PropertyConditionFlags.None_,
) -> PropertyCondition:
    """Creates a condition to search by a localized control type.

    :param localized_control_type: Localized Control Type
    :param condition_flags_property_condition_flags: Contains values used in creating property conditions, defaults to PropertyConditionFlags.none
    :return: Property Condition
    """
    return PropertyCondition(
        cs_condition=self.raw_cf.ByLocalizedControlType(
            localized_control_type, condition_flags_property_condition_flags.value
        )
    )

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
def by_name(
    self, name: str, condition_flags_property_condition_flags: PropertyConditionFlags = PropertyConditionFlags.None_
) -> PropertyCondition:
    """Creates a condition to search by a name.

    :param name: Name
    :param condition_flags_property_condition_flags: Contains values used in creating property conditions, defaults to PropertyConditionFlags.none
    :return: Property Condition
    """
    return PropertyCondition(cs_condition=self.raw_cf.ByName(name, condition_flags_property_condition_flags.value))

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
def by_process_id(self, process_id: int) -> PropertyCondition:
    """Creates a condition to search by a process id.

    :param process_id: Process ID
    :return: Property Condition
    """
    return PropertyCondition(cs_condition=self.raw_cf.ByProcessId(process_id))

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
def by_text(
    self, text: str, condition_flags_property_condition_flags: PropertyConditionFlags = PropertyConditionFlags.None_
) -> PropertyCondition:
    """Creates a condition to search by a text.

    :param text: Text value
    :param condition_flags_property_condition_flags: Contains values used in creating property conditions, defaults to PropertyConditionFlags.none
    :return: Property Condition
    """
    return PropertyCondition(cs_condition=self.raw_cf.ByText(text, condition_flags_property_condition_flags.value))

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
def by_value(
    self,
    value: str,
    condition_flags_property_condition_flags: PropertyConditionFlags = PropertyConditionFlags.None_,
) -> PropertyCondition:
    """Creates a condition to search by a value.

    :param value: Value
    :param condition_flags_property_condition_flags: Contains values used in creating property conditions, defaults to PropertyConditionFlags.none
    :return: Property Condition
    """
    return PropertyCondition(
        cs_condition=self.raw_cf.ByValue(value, condition_flags_property_condition_flags.value)
    )

grid()

Searches for a DataGrid/List.

Returns:

Type Description
PropertyCondition

Property Condition

Source code in flaui/core/condition_factory.py
def grid(self) -> PropertyCondition:
    """Searches for a DataGrid/List.

    :return: Property Condition
    """
    return PropertyCondition(cs_condition=self.raw_cf.Grid())

horizontal_scroll_bar()

Searches for a horizontal scrollbar.

Returns:

Type Description
PropertyCondition

Property Condition

Source code in flaui/core/condition_factory.py
def horizontal_scroll_bar(self) -> PropertyCondition:
    """Searches for a horizontal scrollbar.

    :return: Property Condition
    """
    return PropertyCondition(cs_condition=self.raw_cf.HorizontalScrollBar())

menu()

Searches for a Menu/MenuBar.

Returns:

Type Description
PropertyCondition

Property Condition

Source code in flaui/core/condition_factory.py
def menu(self) -> PropertyCondition:
    """Searches for a Menu/MenuBar.

    :return: Property Condition
    """
    return PropertyCondition(cs_condition=self.raw_cf.ByControlType(ControlType.Menu.value)).Or(
        self.raw_cf.ByControlType(ControlType.MenuBar.value)
    )

vertical_scroll_bar()

Searches for a vertical scrollbar.

Returns:

Type Description
PropertyCondition

Property Condition

Source code in flaui/core/condition_factory.py
def vertical_scroll_bar(self) -> PropertyCondition:
    """Searches for a vertical scrollbar.

    :return: Property Condition
    """
    return PropertyCondition(cs_condition=self.raw_cf.VerticalScrollBar())