MenuItem Object

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

The MenuItem object provides a program interface to items of the following menus:

  • 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 object provides access to both main, system and context (or shortcut) menu items. Its properties let you determine properties of the menu item.

To obtain the object in scripts, use the Items property of the Menu object.

Members

Example

The following example demonstrates how you can obtain the MenuItem object in your script.

JavaScript, JScript

function MenuItemSample()
{
  var Notepad, Window, MainMenu, FileItem;
  // Obtains the Windows Notepad main menu
  Notepad = Sys.Process("Notepad");
  Window = Notepad.Window("Notepad", "*");
  MainMenu = Window.MainMenu;

  // Obtains the File menu item
  FileItem = MainMenu.Items("File");
  …

}

Python

def MenuItemSample():
  # Obtains the Windows Notepad main menu
  Notepad = Sys.Process("notepad")
  Window = Notepad.Window("Notepad", "*")
  MainMenu = Window.MainMenu

  # Obtains the File menu item
  FileItem = MainMenu.Items["File"]
  # ...

VBScript

Sub MenuItemSample

  ' Obtains the Windows Notepad main menu
  Set Notepad = Sys.Process("Notepad")
  Set Window = Notepad.Window("Notepad", "*")
  Set MainMenu = Window.MainMenu

  ' Obtains the File menu item
  Set FileItem = MainMenu.Items("File")
  …

End Sub

DelphiScript

procedure MenuItemSample();
var Notepad, Window, MainMenu, FileItem;
begin
  // Obtains the Windows Notepad main menu
  Notepad := Sys.Process('Notepad');
  Window := Notepad.Window('Notepad', '*');
  MainMenu := Window.MainMenu;

  // Obtains the File menu item
  FileItem := MainMenu.Items('File');
  …

end;

C++Script, C#Script

function MenuItemSample()
{
  var Notepad, Window, MainMenu, FileItem;
  // Obtains the Windows Notepad main menu
  Notepad = Sys["Process"]("Notepad");
  Window = Notepad["Window"]("Notepad", "*");
  MainMenu = Window["MainMenu"];

  // Obtains the File menu item
  FileItem = MainMenu["Items"]("File");
  …

}

See Also

Working With Menus in Desktop Windows Applications
Working With Standard Windows Controls
Menu Object

Highlight search results