Example Code

Use an Event Structure to Discard Mouse Clicks and Prank Co-workers

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

Download All

Overview

This VI uses an Event Structure to discard mouse clicks and prank co-workers.

Description

There are two types of events that the Event Structure can be configured to handle: Notify Events and Filter Events.

 

Notify events are the most common and only react to what has occurred on the front panel. In this example, a Key Press is a notify event. Any press of the keys on the keyboard will result in the Key Press Case executing. It looks to see which keys were pressed, and from this outputs either a true or false to stop the program. In this way we are able to create a keypress combination, CTRL+C, that will stop the Prank VI from running.

 

Filter events catch an event performed by the user before LabVIEW processes that event. In this example, a Mouse Click, or mouse down, is a filter event. When the program is running, any mouse clicks on the front panel will be registered before they are actually processed. This gives us the ability to discard them without having the clicks act on anything.

 

In the Edit Events window, notify events have green arrows while filter events have red arrows and end in ?'s signifying thier ability to be discarded.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Download and open the VI on a co-worker's computer.
  2. Expand the Front Panel until it covers the entire area of the Desktop, making sure that it overlaps the screen. Be sure that the Block Diagram Window and Context Help Windows are closed. You can even go so far as to hide the Desktop's Task Bar.
  3. Run the VI. As the program runs, it will use a property node to become transparent.
  4. Any mouse clicks made on the desktop will be registered by the event structure and discarded.
  5. Press CRTL+C in order to exit execution of the program. Any other keypresses will be ignored.

 

Additional Information or References

 

Block Diagram of VI

1.png

 

2.png

 

 

For additional information over Event Programming or further examples of event structures in use, check out the links below.

A Powerful New Tool for UI Programming--User Interface Event Programming

Event-Driven Programming in LabVIEW

Filter Keyboard to NumPad

 

Have Fun!

Mallori

 

 

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

Mallori M
National Instruments
Sr Product Manager, Customer Proficiency

ni.com/training

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

Comments
Member
Member
on

you don't have to use Select in last attached picture. The output of AND function is TRUE/FALSE so there's no need to do it.