Picture Method (Desktop Objects)

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

The Desktop.Picture method captures a screenshot of the entire desktop or a specific area. The method returns a Picture object containing the captured image. The captured image can optionally include the image of the mouse cursor.

Declaration

TestObj.Picture(ClientX, ClientY, Width, Height, Mouse)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
ClientX [in]    Optional    Integer Default value: 0   
ClientY [in]    Optional    Integer Default value: 0   
Width [in]    Optional    Integer Default value: -1   
Height [in]    Optional    Integer Default value: -1   
Mouse [in]    Optional    Boolean Default value: True   
Result A Picture object

Applies To

The method is applied to the following object:

View Mode

This method is available in the Object Browser panel and in other panels and dialogs in both Basic and Advanced view modes.

Parameters

The method has the following parameters:

ClientX

The horizontal (X) coordinate of the left edge of the screen area to capture. 0 (default) means the left edge of the screen.

ClientY

The vertical (Y) coordinate of the top edge of the screen area to capture. 0 (default) means the top of the screen.

Width

The width (in pixels) of the screenshot to capture. -1 (default) means the width to the right edge of the screen.

Height

The height (in pixels) of the screenshot to capture. -1 (default) means the height to the bottom of the screen.

Mouse

If True (default), the captured image includes the mouse cursor image; if False, the image of the mouse cursor is not included.

Result Value

A Picture object containing the captured image.

Example

The following code captures the entire screen as a bitmap and inserts the captured image into the test log:

JavaScript, JScript

function PictureToLog()
{
  var w = Sys.Desktop.Picture();
  Log.Picture(w, "Screen Image");
}

Python

def PictureToLog():
  w = Sys.Desktop.Picture()
  Log.Picture(w, "Screen Image")

VBScript

Sub PictureToLog
  Set w = Sys.Desktop.Picture
  Log.Picture w, "Screen Image"
End Sub

DelphiScript

procedure PictureToLog;
var w : OleVariant;
begin
  w := Sys.Desktop.Picture;
  Log.Picture(w, 'Screen Image');
end;

C++Script, C#Script

function PictureToLog()
{
  var w = Sys["Desktop"]["Picture"]();
  Log["Picture"](w, "Screen Image");
}

This example demonstrates how to save a captured image to the Regions collection:

JavaScript, JScript

function PictureToRegions()
{
  var w;
  w = Sys.Desktop.ActiveWindow().Picture(10, 10, 60, 60);
  Regions.AddPicture(w, "Image1_bmp");
}

Python

def PictureToRegions():
  w = Sys.Desktop.ActiveWindow().Picture(10, 10, 60, 60)
  Regions.AddPicture(w, "Image1_bmp")

VBScript

Sub PictureToRegions
  Set w = Sys.Desktop.ActiveWindow().Picture(10, 10, 60, 60)
  Regions.AddPicture w, "Image1_bmp"
End Sub

DelphiScript

procedure PictureToRegions;
var
  w : OleVariant;
begin
  w := Sys.Desktop.ActiveWindow().Picture(10, 10, 60, 60);
  Regions.AddPicture(w, 'Image1_bmp');
end;

C++Script, C#Script

function PictureToRegions()
{
  var w;
  w = Sys["Desktop"]["ActiveWindow"]()["Picture"](10, 10, 60, 60);
  Regions["AddPicture"](w, "Image1_bmp");
}

See Also

Picture Object
Desktop.PictureUnderMouse
Desktop.ActiveWindow
Desktop.Width
Desktop.Height
Desktop.MouseX
Desktop.MouseY

Highlight search results