Programmatically Acquiring a Screenshot in a LabVIEW Executable

Updated Jan 29, 2018

Reported In

Software

  • LabVIEW

Issue Details

I would like to acquire a screenshot while running my LabVIEW application.  How can I do this programmatically once the application has been deployed as an executable?

Solution

LabVIEW provides a simple invoke method, Clipboard.Get Image, which can be used to acquire an image from the Windows Clipboard. However, this invoke method is not supported in the LabVIEW Run-Time environment. 

In order to provide similar functionality for VIs intended to be built into executables, .NET can be used to to access an image stored in the clipboard. 

Using the Call Library Function Node, LabVIEW can access and execute Windows Dynamic Link Library (DLL) Files. In the following example, we use the Call Library Function Node to access user32.dll and call the keybd_event button which enables the simulation of a key press. By simulating the press of the Print Screen button, we can then access image data stored to the clipboard via the use of the .NET method, Clipboard GetImage. 

The VI images below illustrate the process of programmatically saving a screenshot. This VI must be set to run in a single thread (run in UI thread).

The first image shows how to automate pressing the print screen button.



The second image shows how to access the image on the clipboard and save it to a file.


 

WAS THIS ARTICLE HELPFUL?

Not Helpful