Close Action (Menu Controls)

Applies to TestComplete 15.63, last modified on April 10, 2024

Description

Use the Close method to close a menu without selecting any item. If the Menu object corresponds to the main menu of a form, the Close method will also remove focus from the menu (remove highlighting from the selected menu item).

Declaration

TestObj.Close()

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
Result None

Applies To

The method is applied to the following object:

View Mode

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

Result Value

None.

Example

The following example demonstrates how to invoke the Notepad context menu and then close it.

JavaScript, JScript

function MenuSample()
{
  var wndEdit = Sys.Process("Notepad").Window("Notepad", "*").Window("Edit");
  // Invokes the context menu
  wndEdit.ClickR();
  var PopupMenu = wndEdit.PopupMenu;

  …

  // Closes the context menu
  PopupMenu.Close();

}

Python

def MenuSample():
  wndEdit = Sys.Process("Notepad").Window("Notepad", "*").Window("Edit")
  # Invokes the context menu
  wndEdit.ClickR()
  PopupMenu = wndEdit.PopupMenu

  # ...

  # Closes the context menu
  PopupMenu.Close()

VBScript

Sub MenuSample

  Set wndEdit = Sys.Process("Notepad").Window("Notepad", "*").Window("Edit")
  ' Invokes the context menu
  wndEdit.ClickR
  Set PopupMenu = wndEdit.PopupMenu

  …

  ' Closes the context menu
  PopupMenu.Close

End Sub

DelphiScript

procedure MenuSample();
var wndEdit, PopupMenu;
begin
  wndEdit := Sys.Process('Notepad').Window('Notepad', '*').Window('Edit');
  // Invokes the context menu
  wndEdit.ClickR;
  PopupMenu := wndEdit.PopupMenu;

  …

  // Closes the context menu
  PopupMenu.Close;

end;

C++Script, C#Script

function MenuSample()
{
  var wndEdit = Sys["Process"]("Notepad")["Window"]("Notepad", "*")["Window"]("Edit");
  // Invokes the context menu
  wndEdit["ClickR"]();
  var PopupMenu = wndEdit["PopupMenu"];

  …

  // Closes the context menu
  PopupMenu["Close"]();

}

See Also

Count Property (Menu Controls)
Items Property (Menu Controls)
Check Action (Menu Controls)
Click Action (Menu Controls)
Select Action (Menu Controls)

Highlight search results