Join free weekly webinars
Find us on

How to save a runtime screenshot at any time

In Windows you can always make copy the current screen into the clipboard, by pressing the Print Screen button. However, then you will need a graphical editor, where the clipboard data can be pasted and saved. Another limitation is that the clipboard can contain only one screenshot in time. EventIDE offers a better solution for taking screenshots, which is almost as easy, as pressing the Print Screen button. 


First, navigate to the the HQ ribbon tab and browse the properties of the experiment in the property grid. Find the Save Screenshot property and add a proxy variable, to be able control the property in your code. 

Whenever you want to make a screenshot of the current stimulus screen, assign a string containing a full file name to this property in snippets. The screenshot will be saved into the target file after the end of a snippet call. The format of the image file is defined by the extension of the file name: .bmp, .png or .jpg

For example, consider the following code in the Triggered snippet of the Button element. The code saves  the current screen to a file after a button press:

SaveScreenshot = "c:\\temp\\ScreenShot1.png"; // copy the current screen into a png file


If you prefer to save screenshot images in other formats, like bmp or jpg, change the extension of file in the name:

SaveScreenshot = "c:\\temp\\ScreenShot1.bmp"; // copy the current screen into a bmp file


Note, that a string file name in C# is defined with double slashes.