WindowSnapshot

(Engine-Level Function)

Description: Creates an image file containing a screen capture of the specified window.
Returns: Boolean indicating success (TRUE) or failure of the operation.
Usage: Script Only.
Function Groups: Window
Related to:
Format: WindowSnapshot(Filename, WindowObj, MimeType[, Left, Top, Right, Bottom] );
Parameters:  
Filename   
Required. Any expression that is a string, or an array of strings containing the full filename(s) to which the screen capture should be saved.
WindowObj   
Required. An object (often, "Self()") specifying the window to be captured.
MimeType   
Required. Any expression that is a string, or an array of strings specifying the mime type(s) to be used for the image.
Left, Top, Right, Bottom
Optional. Short integer values, providing the bounding area of the region to be captured within the window. If any one of these parameters is provided, all four must be provided.  If not provided, a snapshot will be taken of the entire window.
Comments:

Available mime types include image/bmp,  image/jpeg,  image/gif,  image/tiff,  image/png.
Note: Runs asynchronously from a VTScada Internet Client. In this case, the return value is meaningless.

Within an Anywhere Client session, this function does nothing.

Example:

[
  Mimetypes                   { Set of mime types we can snapshot to            };
  Filetypes                   { Corresponding file types (extensions)           };
  SelectedMimetype            { Work var - iterator through above arrays        };
  Constant #NUM_TYPES = 5     { Number of entries in the above arrays           };
]
Init [
  {***** Allow enough time for the window to paint *****}
  If Timeout(1, 1) TakeSnapshots;
  [
    Mimetypes = New(#NUM_TYPES);
    Mimetypes[0] = "image/bmp";
    Mimetypes[1] = "image/jpeg";
    Mimetypes[2] = "image/gif";
    Mimetypes[3] = "image/tiff";
    Mimetypes[4] = "image/png";
    Filetypes = New(#NUM_TYPES);
    Filetypes[0] = "bmp";
    Filetypes[1] = "jpg";
    Filetypes[2] = "gif";
    Filetypes[3] = "tiff";
    Filetypes[4] = "png";
    SelectedMimetype = 0;
  ]
]

TakeSnapshots [
  {***** Snapshot the window for each mime type *****}
  If SelectedMimeType < #NUM_TYPES;
  [
    WindowSnapshot(Concat(PathString, "\Lighthouse.", FileTypes[SelectedMimetype]),
                   Self(),
                   Mimetypes[SelectedMimetype]);
    SelectedMimetype++;
  ]