Wrapper around Menu’s and Menu items

These wrappers allow you to work easily with menu items. You can select or click on items and check if they are checked or unchecked.

class pywinauto.controls.menuwrapper.Menu(owner_ctrl, menuhandle, is_main_menu=True, owner_item=None)

Bases: object

A simple wrapper around a menu handle

A menu supports methods for querying the menu and getting it’s menu items.

get_menu_path(path, path_items=None, appdata=None, exact=False)

Walk the items in this menu to find the item specified by a path

The path is specified by a list of items separated by ‘->’. Each item can be either a string (can include spaces) e.g. “Save As” or a zero based index of the item to return prefaced by # e.g. #1 or an ID of the item prefaced by $ specifier.

These can be mixed as necessary. For example:
  • “#0 -> Save As”,
  • “$23453 -> Save As”,
  • “Tools -> #0 -> Configure”

Text matching is done using a ‘best match’ fuzzy algorithm, so you don’t have to add all punctuation, ellipses, etc. ID matching is performed against wID field of MENUITEMINFO structure (


Return the properties for the menu as a list of dictionaries

This method is actually recursive. It calls get_properties() for each of the items. If the item has a sub menu it will call this get_properties to get the sub menu items.

item(index, exact=False)

Return a specific menu item

  • index is the 0 based index or text of the menu item you want.

  • exact is True means exact matching for item text,

    False means best matching.


Return the count of items in this menu


Return a list of all the items in this menu

exception pywinauto.controls.menuwrapper.MenuInaccessible

Bases: RuntimeError

Raised when a menu has handle but inaccessible.

class pywinauto.controls.menuwrapper.MenuInfo

Bases: object

class pywinauto.controls.menuwrapper.MenuItem(ctrl, menu, index, on_main_menu=False)

Bases: object

Wrap a menu item


Select the menu item

This will send a message to the parent window that the item was picked.


Click on the menu item in a more realistic way

If the menu is open it will click with the mouse event on the item. If the menu is not open each of it’s parent’s will be opened until the item is visible.


Return friendly class name


Return the properties for the item as a dict

If this item opens a sub menu then call Menu.get_properties() to return the list of items in the sub menu. This is avialable under the ‘menu_items’ key.


Return the index of this menu item


Return True if the item is checked.


Return True if the item is enabled.


Return the ID of this menu item


Return the Type of this menu item


See for further information.


Get the rectangle of the menu item


Select the menu item

This will send a message to the parent window that the item was picked.


Return the state of this menu item


Return the SubMenu or None if no submenu


Return the text of this menu item

class pywinauto.controls.menuwrapper.MenuItemInfo

Bases: object

exception pywinauto.controls.menuwrapper.MenuItemNotEnabled

Bases: RuntimeError

Raised when a menu item is not enabled


Decorator for Menu instance methods