Click menu item, get state

Syntax1 - click

men[+] menuid|menupath [window]


Syntax2 - get state

int men(menuid|menupath [window])



window - top-level window with menu. Default: active window.

menuid - menu item identifier. Integer.

menupath - path to menu item, like "&File\&Open".



+ system menu (menu that appears when you right click window title bar).




Simulates menu click. It posts WM_COMMAND or WM_SYSCOMMAND message. Usually works even if window is inactive or hidden. Doesn't work with most nonstandard menus, especially when used menupath.


You can record menu commands. It is the way to know menu item id. To start recording, click menu Tools -> Record Menu. Not all menus can be recorded. If does not record, it means that men cannot be used with that menu.


The speed depends on spe.



Returns menu item state. It is combination of MF_... flags, eg MF_CHECKED, documented in MSDN library. Often menu items are updated just before showing the menu (not immediately after you click a menu item), therefore to get correct menu item state may need to temporarily show the menu, eg with key, then call men.



 Click  menu item with id=3 in "Notepad" window:
men 3 "Notepad"
 Click menu "Select All" in "Notepad" window:
men "&Edit\Sel" "Notepad"
 Click menu Options->Font->Large in window with class name "HH Parent":
men "&Options\&Font\&Large" "+HH Parent"