SaveToClipboard Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The Picture.SaveToClipboard method lets you save the image represented by the Picture object to the Clipboard in order to paste the image somewhere else later.

Note that you can also copy the image to the clipboard by assigning the corresponding Picture object to the Sys.Clipboard property.

Declaration

PictureObj.SaveToClipboard()

PictureObj An expression, variable or parameter that specifies a reference to a Picture object
Result None

Applies To

The method is applied to the following object:

Result Value

None.

Example

The following example demonstrates how to post an image’s handle to the log and how to save an image to the clipboard.

JavaScript, JScript

function Test()
{
  var Pict = Utils.Picture;
  Pict.LoadFromFile("D:\\Data\\my_image.png");

  // Posts the handle of an image to the log
  Log.Message(Pict.Handle);

  // Saves the image to the clipboard
  Pict1.SaveToClipboard();

  // Retrieves the data from the clipboard and posts it to the log
  Log.Picture(Sys.Clipboard);
}

Python

def Test():
  Pict = Utils.Picture
  Pict.LoadFromFile("D:\\Data\\my_image.png")
  # Posts the handle of an image to the log
  Log.Message(Pict.Handle)
  # Saves the image to the clipboard
  Pict.SaveToClipboard()
  # Retrieves the data from the clipboard and posts it to the log
  Log.Picture(Sys.Clipboard)

VBScript

Sub Test
  Dim Pict
  Set Pict = Utils.Picture
  Call Pict.LoadFromFile("D:\Data\my_image.png")

  ' Posts the handle of an image to the log
  Call Log.Message(Pict.Handle)

  ' Saves the image to the clipboard
  Call Pict.SaveToClipboard

  ' Retrieves the data from the clipboard and posts it to the log
  Call Log.Picture(Sys.Clipboard)
End Sub

DelphiScript

procedure Test;
var Pict;
begin
  Pict := Utils.Picture;
  Pict.LoadFromFile('D:\Data\my_image.png');

  // Posts the handle of an image to the log
  Log.Message(Pict.Handle);

  // Saves the image to the clipboard
  Pict.SaveToClipboard;

  // Retrieves the data from the clipboard and posts it to the log
  Log.Picture(Sys.Clipboard);
end;

C++Script, C#Script

function Test()
{
  var Pict = Utils["Picture"];
  Pict["LoadFromFile"]("D:\\Data\\my_image.png");

  // Posts the handle of an image to the log
  Log["Message"](Pict["Handle"]);

  // Saves the image to the clipboard
  Pict["SaveToClipboard"]();

  // Retrieves the data from the clipboard and posts it to the log
  Log["Picture"](Sys["Clipboard"]);
}

See Also

SaveToFile Method
LoadFromFile Method
Clipboard Property

Highlight search results