Sys.HighlightObject Method

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

Description

The Sys.HighlightObject method displays a blinking frame around the specified window or onscreen object. Note that the object or part of it must be visible on screen. Otherwise, the method will do nothing.

Declaration

Sys.HighlightObject(Object, HighlightCount, Color)

Object [in]    Required    Object    
HighlightCount [in]    Optional    Integer Default value: 10   
Color [in]    Optional    Integer Default value: 255 (red)   
Result None

Applies To

The method is applied to the following object:

Sys

Parameters

The method has the following parameters:

Object

A variable, parameter or expression that specifies the window or object to highlight.

HighlightCount

The number of times the frame around the object will blink. The default value is 10.

Color

The color of the blinking frame around the object. The default color is red.

You can use one of the predefined clNNN color constants listed in the Working With Colors topic. You can also create custom color values from the red, green and blue values (0 through 255) using the RGB function from the Example section below.

Result Value

None.

Remarks

Web page elements can be highlighted only if the web page zoom is 100%. See Preparing Web Browsers to learn how to set the zoom in various browsers.

Example

The following script launches Notepad and highlights its main window with the orange color.

JavaScript, JScript

function Main()
{
  WshShell.Run("notepad");

  var wndNotepad = Sys.Process("notepad").Window("Notepad");
  wndNotepad.Activate();

  var orange = RGB(255, 127, 0);

  Sys.HighlightObject(wndNotepad, 10, orange);
}

// Returns a color with the specified red, green and blue components.
// Each component should be in the range 0 .. 255.
function RGB(r, g, b)
{
  // Ensure the color components are in the range 0 .. 255
  var rr = CorrectRGBComponent(r);
  var gg = CorrectRGBComponent(g);
  var bb = CorrectRGBComponent(b);
  return rr | (gg << 8) | (bb << 16);
}

// Clips the specified number to the range 0 .. 255
function CorrectRGBComponent(value)
{
  var val = aqConvert.VarToInt(value);

  if (val < 0) return 0;
  if (val > 255) return 255;
  return val;
}

Python

def Main():
  WshShell.Run("notepad")

  wndNotepad = Sys.Process("notepad").Window("Notepad")
  wndNotepad.Activate()

  orange = RGB(255, 127, 0)

  Sys.HighlightObject(wndNotepad, 10, orange)

# Returns a color with the specified red, green and blue components.
# Each component should be in the range 0 .. 255.
def RGB(r, g, b):
  # Ensure the color components are in the range 0 .. 255
  rr = CorrectRGBComponent(r);
  gg = CorrectRGBComponent(g);
  bb = CorrectRGBComponent(b);
  return rr | (gg << 8) | (bb << 16);

# Clips the specified number to the range 0 .. 255
def CorrectRGBComponent(value):
  val = aqConvert.VarToInt(value)

  if (val < 0):
    return 0
  if (val > 255):
    return 255
  return val

VBScript

Sub Main
  Dim wndNotepad, orange

  WshShell.Run "notepad"
  Set wndNotepad = Sys.Process("notepad").Window("Notepad")
  wndNotepad.Activate

  orange = RGB(255, 127, 0)

  Sys.HighlightObject wndNotepad, 10, orange
End Sub

' Returns a color with the specified red, green and blue components.
' Each component should be in the range 0 .. 255.
Function RGB(r, g, b)
  Dim rr, gg, bb
  ' Ensure the color components are in the range 0 .. 255
  rr = CorrectRGBComponent(r)
  gg = CorrectRGBComponent(g)
  bb = CorrectRGBComponent(b)

  RGB = rr + (gg * 256) + (bb * 65536)
End Function

' Clips the specified number to the range 0 .. 255
Function CorrectRGBComponent(value)
  Dim val
  val = aqConvert.VarToInt(value)

  If val < 0 Then
    val = 0
  ElseIf val > 255 Then
    val = 255
  End If
  CorrectRGBComponent = val
End Function

DelphiScript

// Clips the specified number to the range 0 .. 255
function CorrectRGBComponent(value);
var val;
begin
  val := aqConvert.VarToInt(value);

  if val < 0 then
    val := 0
  else if value > 255 then
    val := 255;

  Result := val;
end;

// Returns a color with the specified red, green and blue components.
// Each component should be in the range 0 .. 255.
function RGB(r, g, b);
var rr, gg, bb;
begin
  // Ensure the color components are in the range 0 .. 255
  rr := CorrectRGBComponent(r);
  gg := CorrectRGBComponent(g);
  bb := CorrectRGBComponent(b);
  Result := rr or (gg shl 8) or (bb shl 16);
end;

procedure Main;
var wndNotepad, orange;
begin
  WshShell.Run('notepad');

  wndNotepad := Sys.Process('notepad').Window('Notepad');
  wndNotepad.Activate;

  orange := RGB(255, 127, 0);

  Sys.HighlightObject(wndNotepad, 10, orange);
end;

C++Script, C#Script

function Main()
{
  WshShell["Run"]("notepad");

  var wndNotepad = Sys["Process"]("notepad")["Window"]("Notepad");
  wndNotepad["Activate"]();

  var orange = RGB(255, 127, 0);

  Sys["HighlightObject"](wndNotepad, 10, orange);
}

// Returns a color with the specified red, green and blue components.
// Each component should be in the range 0 .. 255.
function RGB(r, g, b)
{
  // Ensure the color components are in the range 0 .. 255
  var rr = CorrectRGBComponent(r);
  var gg = CorrectRGBComponent(g);
  var bb = CorrectRGBComponent(b);
  return rr | (gg << 8) | (bb << 16);
}

// Clips the specified number to the range 0 .. 255
function CorrectRGBComponent(value)
{
  var val = aqConvert["VarToInt"](value);

  if (val < 0) return 0;
  if (val > 255) return 255;
  return val;
}

See Also

ObjectFromPoint Method
Window Object
Onscreen Object
Working With Colors

Highlight search results