Skip to content

Tools

Utility helpers ported from FlaUI.Core.Tools. ItemRealizer realizes virtualized items, AccessibilityTextResolver resolves MSAA role/state text, WindowsStoreAppLauncher launches UWP apps, LocalizedStrings exposes culture-aware UI strings, and SystemInfo reports CPU/memory metrics (pure-Python via psutil).

flaui.core.tools.ItemRealizer

Realizes virtualized items in a container so they become full members of the automation tree.

Mirrors C# FlaUI.Core.Tools.ItemRealizer; delegates to the native implementation, which uses the Scroll and ItemContainer patterns to walk and realize each item.

realize_items(item_container_element) staticmethod

Realize all virtualized items in the given container element.

Parameters:

Name Type Description Default
item_container_element AutomationElement

The container whose items should be realized.

required
Source code in flaui/core/tools.py
@staticmethod
def realize_items(item_container_element: "AutomationElement") -> None:
    """Realize all virtualized items in the given container element.

    :param item_container_element: The container whose items should be realized.
    """
    from FlaUI.Core.Tools import ItemRealizer as CSItemRealizer  # pyright: ignore

    CSItemRealizer.RealizeItems(item_container_element.raw_element)

flaui.core.tools.AccessibilityTextResolver

Resolves human-readable text for MSAA accessibility roles and states.

Mirrors C# FlaUI.Core.Tools.AccessibilityTextResolver (a thin wrapper over oleacc). Roles/states are the C# AccessibilityRole / AccessibilityState values, e.g. those returned by element.patterns.legacy_i_accessible.pattern.role.value.

get_role_text(role) staticmethod

Return the localized text for an accessibility role.

Parameters:

Name Type Description Default
role Any

The C# AccessibilityRole value.

required

Returns:

Type Description
str

Human-readable role text (e.g. "push button").

Source code in flaui/core/tools.py
@staticmethod
def get_role_text(role: Any) -> str:
    """Return the localized text for an accessibility role.

    :param role: The C# ``AccessibilityRole`` value.
    :return: Human-readable role text (e.g. ``"push button"``).
    """
    from FlaUI.Core.Tools import AccessibilityTextResolver as CSResolver  # pyright: ignore

    return CSResolver.GetRoleText(role)

get_state_bit_text(state) staticmethod

Return the localized text for a single accessibility state bit.

Parameters:

Name Type Description Default
state Any

The C# AccessibilityState value (single bit).

required

Returns:

Type Description
str

Human-readable state text (e.g. "focused").

Source code in flaui/core/tools.py
@staticmethod
def get_state_bit_text(state: Any) -> str:
    """Return the localized text for a single accessibility state bit.

    :param state: The C# ``AccessibilityState`` value (single bit).
    :return: Human-readable state text (e.g. ``"focused"``).
    """
    from FlaUI.Core.Tools import AccessibilityTextResolver as CSResolver  # pyright: ignore

    return CSResolver.GetStateBitText(state)

get_state_text(state) staticmethod

Return the comma-separated localized text for all set accessibility state flags.

Parameters:

Name Type Description Default
state Any

The C# AccessibilityState value (possibly multiple flags).

required

Returns:

Type Description
str

Comma-separated human-readable state text.

Source code in flaui/core/tools.py
@staticmethod
def get_state_text(state: Any) -> str:
    """Return the comma-separated localized text for all set accessibility state flags.

    :param state: The C# ``AccessibilityState`` value (possibly multiple flags).
    :return: Comma-separated human-readable state text.
    """
    from FlaUI.Core.Tools import AccessibilityTextResolver as CSResolver  # pyright: ignore

    return CSResolver.GetStateText(state)

flaui.core.tools.WindowsStoreAppLauncher

Launches Windows Store (UWP) apps by their Application User Model ID.

Mirrors C# FlaUI.Core.Tools.WindowsStoreAppLauncher, which uses the COM IApplicationActivationManager to activate the app.

launch(app_user_model_id, arguments='') staticmethod

Launch a Windows Store app and return its process id.

Parameters:

Name Type Description Default
app_user_model_id str

The Application User Model ID of the app to launch.

required
arguments str

Arguments to pass to the app, defaults to an empty string.

''

Returns:

Type Description
int

The process id of the launched app.

Source code in flaui/core/tools.py
@staticmethod
def launch(app_user_model_id: str, arguments: str = "") -> int:
    """Launch a Windows Store app and return its process id.

    :param app_user_model_id: The Application User Model ID of the app to launch.
    :param arguments: Arguments to pass to the app, defaults to an empty string.
    :return: The process id of the launched app.
    """
    from FlaUI.Core.Tools import WindowsStoreAppLauncher as CSLauncher  # pyright: ignore

    return int(CSLauncher.Launch(app_user_model_id, arguments).Id)

flaui.core.tools.LocalizedStrings

Culture-aware UI strings used by FlaUI (e.g. scroll-bar names per framework/locale).

Mirrors C# FlaUI.Core.Tools.LocalizedStrings; values are read from the native class, which selects strings based on the current OS culture.

horizontal_scroll_bar() classmethod

Return the localized name of a horizontal scroll bar.

Returns:

Type Description
str

Localized horizontal scroll-bar name.

Source code in flaui/core/tools.py
@classmethod
def horizontal_scroll_bar(cls) -> str:
    """Return the localized name of a horizontal scroll bar.

    :return: Localized horizontal scroll-bar name.
    """
    return cls._get("HorizontalScrollBar")

vertical_scroll_bar() classmethod

Return the localized name of a vertical scroll bar.

Returns:

Type Description
str

Localized vertical scroll-bar name.

Source code in flaui/core/tools.py
@classmethod
def vertical_scroll_bar(cls) -> str:
    """Return the localized name of a vertical scroll bar.

    :return: Localized vertical scroll-bar name.
    """
    return cls._get("VerticalScrollBar")

flaui.core.tools.SystemInfo

System CPU and memory metrics, implemented in pure Python via :mod:psutil.

Python-native equivalent of C# FlaUI.Core.Tools.SystemInfo (the C# version uses PerformanceCounter / WMI). Memory values are bytes; percentages are 0-100 floats.

cpu_usage() staticmethod

Return the current system-wide CPU utilization as a percentage (0-100).

Returns:

Type Description
float

CPU usage percentage.

Source code in flaui/core/tools.py
@staticmethod
def cpu_usage() -> float:
    """Return the current system-wide CPU utilization as a percentage (0-100).

    :return: CPU usage percentage.
    """
    return psutil.cpu_percent()

physical_memory_free() staticmethod

Return the available physical memory in bytes.

Returns:

Type Description
int

Available physical memory (bytes).

Source code in flaui/core/tools.py
@staticmethod
def physical_memory_free() -> int:
    """Return the available physical memory in bytes.

    :return: Available physical memory (bytes).
    """
    return psutil.virtual_memory().available

physical_memory_free_percent() staticmethod

Return the free physical memory as a percentage (0-100).

Returns:

Type Description
float

Free physical memory percentage.

Source code in flaui/core/tools.py
@staticmethod
def physical_memory_free_percent() -> float:
    """Return the free physical memory as a percentage (0-100).

    :return: Free physical memory percentage.
    """
    return 100.0 - psutil.virtual_memory().percent

physical_memory_total() staticmethod

Return the total physical memory in bytes.

Returns:

Type Description
int

Total physical memory (bytes).

Source code in flaui/core/tools.py
@staticmethod
def physical_memory_total() -> int:
    """Return the total physical memory in bytes.

    :return: Total physical memory (bytes).
    """
    return psutil.virtual_memory().total

physical_memory_used() staticmethod

Return the used physical memory in bytes.

Returns:

Type Description
int

Used physical memory (bytes).

Source code in flaui/core/tools.py
@staticmethod
def physical_memory_used() -> int:
    """Return the used physical memory in bytes.

    :return: Used physical memory (bytes).
    """
    return psutil.virtual_memory().used

physical_memory_used_percent() staticmethod

Return the used physical memory as a percentage (0-100).

Returns:

Type Description
float

Used physical memory percentage.

Source code in flaui/core/tools.py
@staticmethod
def physical_memory_used_percent() -> float:
    """Return the used physical memory as a percentage (0-100).

    :return: Used physical memory percentage.
    """
    return psutil.virtual_memory().percent

virtual_memory_free() staticmethod

Return the free virtual (swap/page-file) memory in bytes.

Returns:

Type Description
int

Free virtual memory (bytes).

Source code in flaui/core/tools.py
@staticmethod
def virtual_memory_free() -> int:
    """Return the free virtual (swap/page-file) memory in bytes.

    :return: Free virtual memory (bytes).
    """
    return psutil.swap_memory().free

virtual_memory_total() staticmethod

Return the total virtual (swap/page-file) memory in bytes.

Returns:

Type Description
int

Total virtual memory (bytes).

Source code in flaui/core/tools.py
@staticmethod
def virtual_memory_total() -> int:
    """Return the total virtual (swap/page-file) memory in bytes.

    :return: Total virtual memory (bytes).
    """
    return psutil.swap_memory().total

virtual_memory_used() staticmethod

Return the used virtual (swap/page-file) memory in bytes.

Returns:

Type Description
int

Used virtual memory (bytes).

Source code in flaui/core/tools.py
@staticmethod
def virtual_memory_used() -> int:
    """Return the used virtual (swap/page-file) memory in bytes.

    :return: Used virtual memory (bytes).
    """
    return psutil.swap_memory().used