Id Property (MenuItem Objects)

Applies to TestComplete 15.45, last modified on December 01, 2022

Description

The MenuItem.Id property returns the unique value associated with an item by the application.

Declaration

TestObj.Id

Read-Only Property Integer
TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section

Applies To

The property is applied to the following object:

View Mode

To view this property in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Property Value

The unique value associated with an item by the application.

Example

The following code snippet determines the identifier of the File menu item of the Windows Notepad main menu.

JavaScript, JScript

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

  FileItem = MainMenu.Items("File");
  // Obtains the item’s ID
  ID = FileItem.Id;
  Log.Message("The File menu item id is " + aqConvert.IntToStr(ID));

}

Python

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

  FileItem = MainMenu.Items["File"]
  # Obtains the item's ID
  ID = FileItem.Id
  Log.Message("The File menu item id is " + aqConvert.IntToStr(ID))

VBScript

Sub MenuItemSample

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

  Set FileItem = MainMenu.Items("File")
  ' Obtains the item’s ID
  ID = FileItem.Id
  Log.Message "The File menu item id is " & aqConvert.IntToStr(ID)

End Sub

DelphiScript

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

  FileItem := MainMenu.Items['File'];
  // Obtains the item’s ID
  ID := FileItem.Id;
  Log.Message('The File menu item id is ' + aqConvert.IntToStr(ID));

end;

C++Script, C#Script

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

  FileItem = MainMenu["Items"]("File");
  // Obtains the item’s ID
  ID = FileItem["Id"];
  Log["Message"]("The File menu item id is " + aqConvert["IntToStr"](ID));

}

See Also

IsSeparator Property (MenuItem Objects)
Caption Property (MenuItem Objects)
Position Property (MenuItem Objects)

Highlight search results