Description
If the item opens a sub menu, the SubMenu
property returns this sub menu as a Menu
object. Then you can work with the sub menu like with an ordinary menu.
Declaration
TestObj.SubMenu
Read-Only Property | A Menu object |
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
A Menu
object that corresponds to the submenu.
Remarks
Note concerning GWT MenuBar controls: Due to the specifics of GWT MenuBar controls, you can access submenus via the SubMenu
property only when the menu is visible. In order to get access to a submenu, you should invoke it first. Otherwise, the “Cannot obtain the popup menu” error will occur.
Example
The following code snippet obtains the File submenu of the Windows Notepad main menu.
JavaScript, JScript
function MenuItemSample()
{
// Obtains the Windows Notepad main menu
var MainMenu = Sys.Process("Notepad").Window("Notepad", "*").MainMenu;
// Obtains the File menu item
var FileItem = MainMenu.Items("File");
// Obtains the File menu
var FileMenu = FileItem.SubMenu;
…
}
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 File menu
FileMenu = FileItem.SubMenu
# ...
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 File menu
Set FileMenu = FileItem.SubMenu
…
End Sub
DelphiScript
procedure MenuItemSample();
var MainMenu, FileItem, FileMenu;
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 File menu
FileMenu := FileItem.SubMenu;
…
end;
C++Script, C#Script
function MenuItemSample()
{
// Obtains the Windows Notepad main menu
var MainMenu = Sys["Process"]("Notepad")["Window"]("Notepad", "*")["MainMenu"];
// Obtains the File menu item
var FileItem = MainMenu["Items"]("File");
// Obtains the File menu
var FileMenu = FileItem["SubMenu"];
…
}