Point Object

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

The Point object represents a pixel on the screen. To get an empty Point object, call the Point method of the Utils object.

Members

Example

The following example demonstrates how you can use the Point object. It creates a Point object that specifies the control-relative coordinates and uses these coordinates to simulate a click over the control. Then it creates another Point object that contains the screen-relative coordinates of the performed click.

JavaScript, JScript

function PointSample()
{

  var ScreenPoint, ControlPoint, TestBtn;

  …

  // Obtains the test control
  TestBtn = Aliases.SampleApplication.MainForm.btn;

  // Creates a Point object and specifies the control-related coordinates
  ControlPoint = Utils.Point;
  ControlPoint.X = 3;
  ControlPoint.Y = 5;
  // Simulates a click over the control at the specified point
  TestBtn.Click(ControlPoint.X, ControlPoint.Y);

  // Creates a Point object that holds the screen-related coordinates
  ScreenPoint = TestBtn.WindowToScreen(ControlPoint.X, ControlPoint.Y);
  …

}

Python

def PointSample():
  # ...
  # Obtains the test control
  TestBtn = Aliases.SampleApplication.MainForm.btn
  # Creates a Point object and specifies the control-related coordinates
  ControlPoint = Utils.Point
  ControlPoint.X = 3
  ControlPoint.Y = 5
  # Simulates a click over the control at the specified point
  TestBtn.Click(ControlPoint.X, ControlPoint.Y)
  # Creates a Point object that holds the screen-related coordinates
  ScreenPoint = TestBtn.WindowToScreen(ControlPoint.X, ControlPoint.Y)
  # ...

VBScript

Sub PointSample

  Dim ScreenPoint, ControlPoint, TestBtn

  …

  ' Obtains the test control
  Set TestBtn = Aliases.SampleApplication.MainForm.btn

  ' Creates a Point object and specifies the control-related coordinates
  Set ControlPoint = Utils.Point
  ControlPoint.X = 3
  ControlPoint.Y = 5
  ' Simulates a click over the control at the specified point
  Call TestBtn.Click(ControlPoint.X, ControlPoint.Y)

  ' Creates a Point object that holds the screen-related coordinates
  Set ScreenPoint = TestBtn.WindowToScreen(ControlPoint.X, ControlPoint.Y)
  …

End Sub

DelphiScript

procedure PointSample();
var ScreenPoint, ControlPoint, TestBtn, Text, SourceText;

begin

  …

  // Obtains the test control
  TestBtn := Aliases.SampleApplication.MainForm.btn;

  // Creates a Point object and specifies the control-related coordinates
  ControlPoint := Utils.Point;
  ControlPoint.X := 3;
  ControlPoint.Y := 5;
  // Simulates a click over the control at the specified point
  TestBtn.Click(ControlPoint.X, ControlPoint.Y);

  // Creates a Point object that holds the screen-related coordinates
  ScreenPoint := TestBtn.WindowToScreen(ControlPoint.X, ControlPoint.Y);
  …

end;

C++Script, C#Script

function PointSample()
{

  var ScreenPoint, ControlPoint, TestBtn;

  …

  // Obtains the test control
  TestBtn = Aliases["SampleApplication"]["MainForm"]["btn"];

  // Creates a Point object and specifies the control-related coordinates
  ControlPoint = Utils["Point"];
  ControlPoint["X"] = 3;
  ControlPoint["Y"] = 5;
  // Simulates a click over the control at the specified point
  TestBtn["Click"](ControlPoint["X"], ControlPoint["Y"]);

  // Creates a Point object that holds the screen-related coordinates
  ScreenPoint = TestBtn["WindowToScreen"](ControlPoint["X"], ControlPoint["Y"]);
  …

}

See Also

Utils Object
Utils.Point

Highlight search results