To download NI software, including the products shown below, visit ni.com/downloads.
This example uses calls from the Windows user32.dll to programmatically take a screenshot, access the image stored in the clipboard, and save the image to a file. This method can be used in a deployed application whereas innate LabVIEW methods (Clipboard.Get Image) as not available at run-time and cannot be used in an executable.
Steps to Implement or Execute Code
**Note that the VI must be set to run in a single thread (run in UI thread).**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Hi, I'm trying to run this on LV2011F2 and get this error when tryign to save:
Error calling method System.Drawing.Image.Save, (System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.) <append><b>System.Runtime.InteropServices.ExternalException</b> in PrintScreen-LV86-4.vi
Any ideas? This happens with both the VI and a compiled executable. I do have the execution set to UI. Thanks.
For anyone who experienced it, in order for this to work in runtime environment, you have to set up the Call Library function node the way that this thread shows:
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.