Skip to content

MenuItem

flaui.core.automation_elements.MenuItem

Bases: AutomationElement

Class to interact with a menu item element.

is_checked property writable

Gets if a menu item is checked or unchecked, if checking is supported. /// For some applications, like WPF, setting this property doesn't execute the action that happens when a user clicks the menu item, only the checked state is changed. /// For WPF and Windows Forms applications, if you want to execute the action too, you need to use Invoke() method.

Returns:

Type Description
bool

True if checked, else False

is_win_menu property writable

Flag to indicate if the containing menu is a Win32 menu because that one needs special handling

Returns:

Type Description
bool

True if the menu is Win32 model, else False

items property

Gets all MenuItem which are inside this element.

Returns:

Type Description
List[MenuItem]

MenuItems

text property

Gets the text of the element

Returns:

Type Description
str

Element text

collapse()

Collapses the element.

Returns:

Type Description
MenuItem

MenuItem element

Source code in flaui/core/automation_elements.py
@handle_csharp_exceptions
def collapse(self) -> MenuItem:
    """Collapses the element.

    :return: MenuItem element
    """
    return MenuItem(raw_element=self.raw_element.Collapse())

expand()

Expands the element.

Returns:

Type Description
MenuItem

MenuItem element

Source code in flaui/core/automation_elements.py
@handle_csharp_exceptions
def expand(self) -> MenuItem:
    """Expands the element.

    :return: MenuItem element
    """
    return MenuItem(raw_element=self.raw_element.Expand())

get_item_by_name(name)

Gets the menu item by name.

Parameters:

Name Type Description Default
name str

Name of the menu item

required

Returns:

Type Description
MenuItem

MenuItem element

Source code in flaui/core/automation_elements.py
@handle_csharp_exceptions
def get_item_by_name(self, name: str) -> MenuItem:
    """Gets the menu item by name.

    :param name: Name of the menu item
    :return: MenuItem element
    """
    return MenuItem(raw_element=self.raw_element.Items[name])

invoke()

Invokes the element.

Returns:

Type Description
MenuItem

MenuItem element

Source code in flaui/core/automation_elements.py
@handle_csharp_exceptions
def invoke(self) -> MenuItem:
    """Invokes the element.

    :return: MenuItem element
    """
    return MenuItem(raw_element=self.raw_element.Invoke())

set_is_checked(value)

Sets if a menu item is checked or unchecked, if checking is supported. /// For some applications, like WPF, setting this property doesn't execute the action that happens when a user clicks the menu item, only the checked state is changed. /// For WPF and Windows Forms applications, if you want to execute the action too, you need to use Invoke() method.

:value: Flag to set

Returns:

Type Description
None

None

Source code in flaui/core/automation_elements.py
@handle_csharp_exceptions
def set_is_checked(self, value: bool) -> None:
    """Sets if a menu item is checked or unchecked, if checking is supported.
    /// For some applications, like WPF, setting this property doesn't execute the action that happens when a user clicks the menu item, only the checked state is changed.
    /// For WPF and Windows Forms applications, if you want to execute the action too, you need to use Invoke() method.

    :value: Flag to set
    :return: None
    """
    self.raw_element.IsChecked(value)