pywinauto_recorder.player.menu_click

pywinauto_recorder.player.menu_click(menu_path, duration=None, timeout=None, absolute_path=False)[source]

Clicks on the menu items.

Example of code using the ‘menu_click’ function to automate ‘Notepad++’:
from pywinauto_recorder.player import UIPath, find, click, menu_click

with UIPath("RegEx: .* - Notepad\+\+$||Window"):
        find().set_focus()
        menu_click("Language->P->Python")
Example of code using the ‘menu_click’ function to automate ‘WordPad’:
from pywinauto_recorder.player import UIPath, find, click, menu_click

with UIPath("Document - WordPad||Window"):
        find().set_focus()
        click("*->File tab||Button")
        menu_click("New")

In the above code, the ‘File tab’ element that opens the menu is not of type ‘MenuItem’, so it is not possible to call ‘menu_click(“File tab->New”)’. In this case the menu must be opened with ‘click(”*->File tab||Button”)’ before calling menu_click().

Parameters
  • menu_path (str) – menu item path

  • duration (Optional[float]) – duration in seconds of the mouse move (it doesn’t take into account the time it takes to find) (if duration is -1 the mouse cursor doesn’t move, it just sends WM_CLICK window message, useful for minimized or non-active window).

  • timeout (Optional[float]) – period of time in seconds that will be allowed to find the element

Return type

UIAWrapper

Returns

Pywinauto wrapper of the first clicked item

Raises

FailedSearch – if an element is not found