Example Code

Send Prompt Message to the User in Front Of All Desktop Applications in 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

Description

This article will guide you through the process of solving the following problems: 

 

  • You would like to notify the user when a certain event happens in LabVIEW. On your station you are simultaneously running multiple programs and you would like the message to be visible to the user or top of all desktop applications. You tried the LabVIEW dialog box method, but it’s only working inside the LabVIEW environment.
  • You would like to send a prompt message to a user on the same network when a certain event in LabVIEW happens. The target computer does not necessarily have LabVIEW installed but you still want to give the user a notification somehow. 

How to Use

You can achieve this goal by calling the msg.exe located in the C:\Windows\System32 folder with the System Exec.vi in LabVIEW. Please follow the listed steps, mind the process is different for 32bit and 64bit LabVIEW:
 

Process for 32 bit LabVIEW:

 
  1. Navigate to the C:\Windows\System32 folder
  2. Locate the msg.exe
  3. Copy the file to the C:\Windows\SysWOW64 folder
  4. Download the attached VI
  5. Open the Block Diagram of the VI
  6. Observe we are using the System Exec.vi to call the external application
  7. Notice the path leads to C:\Windows\System32. Since your application is a 32 bit one, Windows automatically redirects the path from System32 to SysWOW64; that's why it is necessary to copy the msg.exe beforehand. If you do not copy it you will get the following error message when executing the VI from 32bit LabVIEW:     

                                                                       
    User message.JPG
  8. You can modify the 127.0.0.1 localhost IP address in the string constant to send the same prompt message to other computers too on the same network
  9. Run the VI
  10. Open non-LabVIEW applications such as web browser, File Explorer, etc. Observe every 3 second the message "LabVIEW NEEDS YOUR ATTENTION !!!" pops up above any application

The Block Diagram of the attached VI:  

Block Diagram of the attached vi

Process for 64bit LabVIEW:

 
  1. Download the attached VI
  2. Open the Block Diagram of the VI
  3. Observe we are using the System Exec.vi to call the Windows application msg.exe
  4. You can modify the 127.0.0.1 localhost IP address in the string constant to send the same prompt message to other computers on the same network
  5. Run the VI
  6. Open non-LabVIEW applications such as web browser, File Explorer, etc. Observe every 3 seconds the message "LabVIEW NEEDS YOUR ATTENTION !!!" pops up above any application

 

Related Links

Execute Command Line Arguments from LabVIEW
Creating Quality Dialog Boxes in LabVIEW
The Msg Command Syntax

 

 

 

 

 

 

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

Contributors