Applies To:
  • CitectSCADA 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
  • CitectHMI 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
  • CitectFacilities 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0

Summary:
How to automatically create a screenshot of a Citect's page during runtime? For example, I need to capture periodically a screenshot of a trend page and save it as a *.JPG image. 

Solution:

The Windows keyboard's shortcut can be used with the SendKeys() function in order to perform a "print screen" and then paste the clipboard into Microsoft Paint.  

The following cicode shows how to capture a screenshot of the trend page (From the CSV_Example project) and save it as a *.JPG file with Microsoft Paint.

The capture_screen() function can be called from an event in order to get a periodic image of the trend page.

 

FUNCTION capture_screen()

//Memory or Local variable defined in the project

counter=counter+1;

// Open the Trend page of the project

PageDisplay("Trend");

Sleep(1);

// Capture a scrrenshot of the trend page

SendKeys("Trend", "{prtsc}");

// Open Microsoft Paint application. Use Mode '6' if wnat the paint window Minimized

Exec("mspaint", 1);

Sleep(3);

// Paste the clipboard into Paint

SendKeys("untitled - Paint", "^(v)");

Sleep(1);

// Open the 'Save As' menu

SendKeys("untitled - Paint", "^(s)");

Sleep(1);

// Enter the name of the screenshot: image_<screenshot's number>

SendKeys("Save As", "image_" + IntToStr(counter));

Sleep(1);

// Change to the 'save as' field

SendKeys("Save As", "{tab}");

Sleep(1);

// Select 'JPG' as type

SendKeys("Save As", "j");

Sleep(1);

// Save the file

SendKeys("Save As", "{enter}");

Sleep(1);

// Close Paint

SendKeys("image_" + IntToStr(counter) + ".JPG - Paint", "%({f4})");

SleepMS(500);

// Go back to the last page displayed before screenshot

PageLast();

END 

 

Keywords: