Regions Object

Applies to TestComplete 15.64, last modified on May 16, 2024


The Regions object allows you to manage and process images (more precisely, regions of images) that are stored in the Regions section of the Stores collection from your scripts. For example, compare two images, find one image within another, add an image to the collection, update the image stored in the collection and so on.

The Regions object can work with:

  • Image regions that are represented by Picture objects.
  • Objects that have the Picture method which returns a Picture object.

The Regions object contains properties that correspond to the images added to the Stores | Regions collection. The property names coincide with the names of the child images. Each property returns a Region object that corresponds to an appropriate child image. For instance, the following code provides access to the element named Pic1:

JavaScript, JScript

var RegionObj1 = Regions.Pic1;


RegionObj1 = Regions.Pic1


Set RegionObj1 = Regions.Pic1


  RegionObj1 : OleVariant;
  RegionObj1 := Regions.Pic1;

C++Script, C#Script

var RegionObj1 = Regions["Pic1"];


The Regions object is available only if your project contains the Stores | Regions collection.



The following code saves an image of the application’s MainForm object to the Regions collection and then compares the stored image to the active window:

JavaScript, JScript

function Test()
  var w1, w2;
  w1 = Sys.Process("MyApp").Window("MyWndClass", "MyWndCaption", 1);
  Regions.AddPicture(w1, "MyAppWnd");
  w2 = Sys.Desktop.ActiveWindow();
  if(! Regions.Compare("MyAppWnd", w2))
  // -- or --
  // if (! Regions.MyAppWnd.Check(w2))
    Log.Error("The compared regions are not identical.", w2.Name);


def Test():
  w1 = Sys.Process("MyApp").Window("MyWndClass", "MyWndCaption", 1)
  Regions.AddPicture(w1, "MyAppWnd")
  w2 = Sys.Desktop.ActiveWindow()
  if not Regions.Compare("MyAppWnd", w2):
  # -- or -- 
  # if not Regions.MyAppWnd.Check(w2):
    Log.Error("The compared regions are not identical.", w2.Name)


Sub Test
  Set w1 = Sys.Process("MyApp").Window("MyWndClass", "MyWndCaption", 1)
  Call Regions.AddPicture(w1, "MyAppWnd")
  Set w2 = Sys.Desktop.ActiveWindow
  If Not Regions.Compare("MyAppWnd", w2) Then
  ' -- or --
  ' If Not Regions.MyAppWnd.Check(w2) Then
    Log.Error "The compared regions are not identical.", w2.Name
  End If
End Sub


procedure Test;
  w1, w2 : OleVariant;
  w1 := Sys.Process('MyApp').Window('MyWndClass', 'MyWndCaption', 1);
  Regions.AddPicture(w1, 'MyAppWnd');
  w2 := Sys.Desktop.ActiveWindow;
  if not Regions.Compare('MyAppWnd', w2) then
  // -- or --
  // if not Regions.MyAppWnd.Check(w2) then
    Log.Error('The compared regions are not identical.', w2.Name);

C++Script, C#Script

function Test()
  var w1, w2;
  w1 = Sys["Process"]("MyApp")["Window"]("MyWndClass", "MyWndCaption", 1);
  Regions["AddPicture"](w1, "MyAppWnd");
  w2 = Sys["Desktop"]["ActiveWindow"]();
  if(! Regions["Compare"]("MyAppWnd", w2))
  // -- or --
  // if (! Regions["MyAppWnd"]["Check"](w2))
    Log["Error"]("The compared regions are not identical.", w2.Name);

See Also

Files Object
Objects Object
About Regions Collection
Picture Object
Region Object

Highlight search results