Getting HotKey Text

Applies to TestComplete 14.71, last modified on April 22, 2021

While testing HotKey controls, you can use specific properties and methods of the corresponding program object to perform certain actions and obtain data stored in controls. You can call these methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with the needed properties and methods from your scripts. However, when testing a control from your keyword test, you can use the same methods and properties calling them from keyword test operations. For more information, see Keyword Tests Basic Operations.

To obtain the text (a key combination) that is currently displayed in the HotKey control, use the wText property of the Win32HotKey object. TestComplete associates this object with all HotKey controls whose class names are listed in the Object Mapping options of your project. The wText property returns the current key combination of the HotKey control.

Below is an example that demonstrates how you can obtain the text that is currently displayed in the HotKey control:

JavaScript, JScript

function main()
{
  var HotKey;
    
  // Obtain the HotKey control
  HotKey = Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("THotKey", "", 1);
  
  // Get the text
  Log.Message (HotKey.wText);
}

Python

def Main():
    
  # Obtain the HotKey control
  HotKey = Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("THotKey", "", 1)
  
  # Get the text
  Log.Message (HotKey.wText)

VBScript

Sub main
  Dim HotKey
    
  ' Obtain the HotKey control
  Set HotKey = Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("THotKey", "", 1)

  ' Get the text
  Log.Message HotKey.wText
End Sub

DelphiScript

procedure main;
var HotKey;
begin

  // Obtain the HotKey control
  HotKey := Sys.Process('Project1').Window('TForm1', 'Form1', 1).Window('THotKey', '', 1);

  // Get the text
  Log.Message (HotKey.wText);
end;

C++Script, C#Script

function main()
{
  var HotKey;
    
  // Obtain the HotKey control
  HotKey = Sys["Process"]("Project1")["Window"]("TForm1", "Form1", 1)["Window"]("THotKey", "", 1);

  // Get the text
  Log.Message(HotKey["wText"]);
}

See Also

Working With HotKey Controls
wText Property (HotKey Controls)

Highlight search results