To take a screenshot from an executable, utilize the Windows user32.dll to take a screenshot and access the stored image from the clipboard. This can be seem in the Programmatically Acquire Screenshot in Executable Application
The structure of the example is to:
- Use Call Library Function Node to access user32.dll (which can be found in C:\Windows\System32\user32.dll).
- Call the keybd_event function which enables the simulation of a key press (seen in figure 1).
- Simulate the press of the Print Screen button which stores the image in the clipboard.
- Access image data stored to the clipboard via the use of the .NET method, Clipboard GetImage (seen in figure 2).
Note: This VI must be set to run in a single thread (run in UI thread).
Figure 1: Using user32.dll calls to simulate pressing the Print Screen keyboard key
Figure 2: Using user32.dll calls to capture the image on the clipboard and save to a file.
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.