Click menu item

Syntax1 - click

men[+] menuid|menupath [window]

 

Syntax2 - get state

int men(menuid|menupath [window])

 

Parts

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

menuid - menu item identifier. Integer.

menupath - path to menu item (sequence of menu labels, separated by backslash). String. Labels can be partial, but from the beginning. Underlined characters must be preceded with &.

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

 

Remarks

Syntax1

Simulates menu click (posts WM_COMMAND or WM_SYSCOMMAND message). Usually, this command 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 record, click menu Tools -> Record Menu. When you select a menu item in some window, is inserted the men command. Not all menus can be recorded. If recording fails, it means that men cannot be used with that menu.

 

Syntax2

Returns menu item state. It is combination of MF_... constants defined in WinConstants function. Often, after menu item is clicked, menu state is not updated until menu is shown next time. Therefore, before men, you can use key command to show menu.

 

Examples

 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"