Example Code

Dialog Box with Timeout using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This code demonstrates a “one button dialog” that closes automatically after a certain time.

 

Description

This code calls a generic "one button dialog" VI that will run in parallel with a "check elapsed time" loop. If the user press the OK button on the dialog box, this will exit the dialog box as usual. However, if the user does not press the OK button on the dialog, the "check elapsed time" loop will call a win32 DLL to programmatically press the Enter key on the keyboard. This will exit the dialog box, as long as the dialog box is the active window.

Note: This VI uses a win32 system DLL (user32.dll) in order to programmatically press the "Enter (Return)" key.

 

Requirements

  • LabVIEW Base Development System 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Open VI "Dialog Box Timeout 2012 NIVerified.vi".
  2. Run the program.
  3. Press the OK button and observe that the dialog box closes as usual.
  4. Run the program again.
  5. Wait for the time specified in "Timeout (s)" and observe that the dialog box closes by itself.

 

Additional Information or References

VI Block Diagram

4-410_BlockDiagram.png

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.