From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Programmatically Acquire Screenshot in Executable Application

제품 및 환경

이 섹션은 예제 생성에 사용된 제품과 OS를 표시합니다.

아래의 제품을 비롯한 NI 소프트웨어를 다운로드하시려면를 방문하십시오.


  • LabVIEW

코드 및 문서


모두 다운로드


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.


How to Use

Steps to Implement or Execute Code

  1. Use snippet below or download the attached LabVIEW code.
    • Provided code is compatible with LabVIEW 2012 and later.
  2. Run VI

**Note that the VI must be set to run in a single thread (run in UI thread).**


Block Diagram.png

James K.
National Instruments
Applications Engineer

NI 커뮤니티에 있는 예제 코드 교환의 예제 코드는 MIT 라이센스로 라이센스가 부여됩니다.

Active Participant
Active Participant

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

Any ideas? This happens with both the VI and a compiled executable. I do have the execution set to UI. Thanks.

Active Participant
Active Participant

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:

Test Engineer at Moog Inc.

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.