Skip to content

Identifiers

Thin Python wrappers around the C# FlaUI.Core.Identifiers types. They expose the native id/name, compare by id, and read availability metadata, while the ids themselves come straight from the C# registry (no re-registration, no drift).

flaui.core.identifiers

Python wrappers for FlaUI C# automation identifiers.

These thin wrappers expose the C# FlaUI.Core.Identifiers types (PropertyId, EventId, PatternId, TextAttributeId) with Pythonic id/name access, value-equality by id, and a readable repr. The ids are sourced from the C# registry, so there is no risk of drift.

EventId

Bases: IdentifierBase

Python wrapper around a C# EventId (identifies an automation event).

IdentifierBase

Bases: BaseModel

Thin Python wrapper around a C# FlaUI identifier.

The wrapper holds the underlying C# identifier instance and exposes its native Id and Name Pythonically. Equality and hashing are based on the id, mirroring the C# behaviour, so wrapped identifiers can be compared and used as dictionary keys. The wrapper deliberately does not re-register identifiers in Python: the ids come straight from the C# registry to avoid drift.

id property

Return the native identifier id.

Returns:

Type Description
int

The integer id assigned by the UI Automation framework.

name property

Return the readable identifier name.

Returns:

Type Description
str

The human-readable identifier name.

__eq__(other)

Return whether two identifiers share the same id (mirrors C# IEquatable).

Parameters:

Name Type Description Default
other object

The object to compare against.

required

Returns:

Type Description
bool

True when both are identifiers with the same id.

Source code in flaui/core/identifiers/identifier_base.py
def __eq__(self, other: object) -> bool:
    """Return whether two identifiers share the same id (mirrors C# ``IEquatable``).

    :param other: The object to compare against.
    :return: ``True`` when both are identifiers with the same id.
    """
    if isinstance(other, IdentifierBase):
        return self.id == other.id
    return NotImplemented

__hash__()

Hash by id, matching C# GetHashCode.

Returns:

Type Description
int

The identifier id used as the hash.

Source code in flaui/core/identifiers/identifier_base.py
def __hash__(self) -> int:
    """Hash by id, matching C# ``GetHashCode``.

    :return: The identifier id used as the hash.
    """
    return self.id

__repr__()

Return 'Name [#Id]' like the C# ToString().

Returns:

Type Description
str

A readable representation of the identifier.

Source code in flaui/core/identifiers/identifier_base.py
def __repr__(self) -> str:
    """Return ``'Name [#Id]'`` like the C# ``ToString()``.

    :return: A readable representation of the identifier.
    """
    return f"{self.name} [#{self.id}]"

validate_raw(v, info) classmethod

Reject a missing C# identifier reference.

Parameters:

Name Type Description Default
v Any

The candidate C# identifier.

required
info ValidationInfo

Pydantic validation context.

required

Returns:

Type Description
Any

The validated C# identifier.

Raises:

Type Description
ValueError

If the identifier reference is None.

Source code in flaui/core/identifiers/identifier_base.py
@field_validator("raw")
@classmethod
def validate_raw(cls, v: Any, info: ValidationInfo) -> Any:
    """Reject a missing C# identifier reference.

    :param v: The candidate C# identifier.
    :param info: Pydantic validation context.
    :return: The validated C# identifier.
    :raises ValueError: If the identifier reference is ``None``.
    """
    if v is None:
        raise ValueError("raw identifier must not be None")
    return v

PatternId

Bases: IdentifierBase

Python wrapper around a C# PatternId (identifies an automation pattern).

availability_property property

Return the property indicating whether the pattern is available, if any.

Returns:

Type Description
Optional[PropertyId]

A :class:PropertyId wrapping the C# availability property, or None when the pattern declares no availability property.

PropertyId

Bases: IdentifierBase

Python wrapper around a C# PropertyId (identifies an automation property).

TextAttributeId

Bases: IdentifierBase

Python wrapper around a C# TextAttributeId (identifies a text-range attribute).