SaveScreenShot

This function takes a screen shot of the project screen and saves it to an image file.

Function Group Execution Windows Embedded Thin Client
SaveScreenShot Graphic Synchronous Supported Supported (only for open screens) Executed on Server

Syntax

SaveScreenShot( { | optStrScreenName { | ,optStrOutputFile { | , { optNumFormat | 0 | 1 | 2 | 3 | 4 | 5 } } } } )
optStrScreenName
The name of a project screen file (*.scr). If no file path is specified, then the file must be located in the Screen sub-folder of the project folder (e.g., \project_name\Screen\screen_name.scr).

For projects running on Windows, the screen may be either open or closed. For projects running on Windows Embedded, the screen must be open.

This is an optional parameter; if no value (or "") is specified, then the currently open and active screen is used.

optStrOutputFile
The name of the output file. If no file path is specified, then the file is saved in the Web sub-folder of the project folder (e.g., \project_name\Web\screen_name.jpg)

This is an optional parameter; if no value is specified, then either the value of optStrScreenName or simply ScreenShot.jpg is used.

optNumFormat
The format of the image file:
Value Description
0 BMP
1 JPG
2 PNG
3 GIF
4 TIFF
5 Auto

This is an optional parameter; if no value is specified, then the default is 1 (JPG).

Returned value

This function returns the following possible values:
Value Description
-1 Wrong number of parameters.
-2 Wrong parameter types.
-3 Invalid directory.
-4 Second parameter cannot be empty.
-5 Wrong format / invalid option for third parameter.
-6 Failed to save file.
-7 Failed to create compatible bitmap.
0 Success.

Notes

The Viewer task must be running for this function to be executed. The function can be called by the Background Task (e.g., by a Script or Math worksheet), but it will fail if the Viewer task is not running.

Examples

Save the currently active screen to \project_name\Web\ScreenShot.JPG:
SaveScreenShot()
Save the screen file main.scr to \project_name\Web\main.JPG:
SaveScreenShot( "main.scr" )
Save the currently active screen as a BMP with the name of the currently logged user:
SaveScreenShot( "", UserName, 0 )