From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com 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 소프트웨어를 다운로드하시려면 ni.com/downloads를 방문하십시오.

    소프트웨어

  • LabVIEW

코드 및 문서

첨부파일

모두 다운로드

Description

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 라이센스로 라이센스가 부여됩니다.

의견
h_yong
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 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.

FireFist-Redhawk
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:

 

https://forums.ni.com/t5/LabVIEW/application-crash-report-user32-dll/td-p/2414136?profile.language=e...

Redhawk
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.