Description
The Menu
object is used to work with menus of various types from scripts:
- Standard Win32 Menu
- Borland Action Menu Bar
- ComponentOne Menus and Toolbars
- Developer Express XtraBars
- Developer Express ASPxMenu
- Infragistics UltraWinToolbars
- GWT MenuBar menus
- Janus UI Controls
- Java applications’ menus
- JavaFX applications’ menus
- Microsoft MenuStrip menus
- Microsoft ContextMenuStrip menus
- Qt applications’ menus
- SAP GUI popup menus
- Syncfusion Essential Tools Menus
- Telerik Menus and ToolBars
- WPF applications’ menus
The Menu
object lets you work with different types of menus - main, system, context menus and submenus. It has specific actions for selecting or checking menu items and properties that provide access to menu items.
Members
Example
The following code snippet demonstrates how to obtain Windows Notepad menus.
JavaScript, JScript
function MenuSample()
{
var Notepad = Sys.Process("Notepad");
var wndNotepad = Notepad.Window("Notepad", "*");
// Obtains the Notepad main menu
var MainMenu = wndNotepad.MainMenu;
…
// Obtains the Notepad system menu
var SystemMenu = wndNotepad.SystemMenu;
…
// Obtains the Notepad context menu
var wndEdit = wndNotepad.Window("Edit");
wndEdit.ClickR();
var PopupMenu = wndEdit.PopupMenu;
…
}
Python
def MenuSample():
Notepad = Sys.Process("notepad");
wndNotepad = Notepad.Window("Notepad", "*")
# Obtains the Notepad main menu
MainMenu = wndNotepad.MainMenu
# ...
# Obtains the Notepad system menu
SystemMenu = wndNotepad.SystemMenu
# ...
# Obtains the Notepad context menu
wndEdit = wndNotepad.Window("Edit")
wndEdit.ClickR()
PopupMenu = wndEdit.PopupMenu
# ...
VBScript
Sub MenuSample
Set Notepad = Sys.Process("Notepad")
Set wndNotepad = Notepad.Window("Notepad", "*")
' Obtains the Notepad main menu
Set MainMenu = wndNotepad.MainMenu
…
' Obtains the Notepad system menu
Set SystemMenu = wndNotepad.SystemMenu
…
' Obtains the Notepad context menu
Set wndEdit = wndnotepad.Window("Edit")
wndEdit.ClickR
Set PopupMenu = wndEdit.PopupMenu
…
End Sub
DelphiScript
procedure MenuSample();
var Notepad, wndNotepad, MainMenu, SystemMenu, wndEdit, PopupMenu;
begin
Notepad := Sys.Process('Notepad');
wndNotepad := Notepad.Window('Notepad', '*');
// Obtains the Notepad main menu
MainMenu := wndNotepad.MainMenu;
…
// Obtains the Notepad system menu
SystemMenu := wndNotepad.SystemMenu;
…
// Obtains the Notepad context menu
wndEdit := wndNotepad.Window('Edit');
wndEdit.ClickR;
PopupMenu := wndEdit.PopupMenu;
…
end;
C++Script, C#Script
function MenuSample()
{
var Notepad = Sys["Process"]("Notepad");
var wndNotepad = Notepad["Window"]("Notepad", "*");
// Obtains the Notepad main menu
var MainMenu = wndNotepad["MainMenu"];
…
// Obtains the Notepad system menu
var SystemMenu = wndNotepad["SystemMenu"];
…
// Obtains the Notepad context menu
var wndEdit = wndNotepad["Window"]("Edit");
wndEdit["ClickR"]();
var PopupMenu = wndEdit["PopupMenu"];
…
}
See Also
Working With Menus in Desktop Windows Applications
Working With Standard Windows Controls
SubMenu Property (MenuItem Objects)
MainMenu Property
PopupMenu Property (Window Objects)
SystemMenu Property
ActionMainMenu Property
C1MainMenu Property
EssMainMenu Property
JMainMenu Property
StripMainMenu Property
UICtrlMainMenu Property
UltraMainMenu Property
XtraMainMenu Property
SwingMenu Property (Specific to JMenuBar Controls)