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.

Example Code

Monitoring Mouse Movement and Clicks

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 VI gives the cursor position of your mouse in any application, and shows which button is being pressed on the mouse.

 

Description

This VI will give you the cursor position of your mouse in any application, not just on the front panel of this particualr VI. It will also show which button is being pressed on the mouse, and the array of 3 button clicks can be expanded to 4 if the user has more mouse buttons. This VI uses several Call Library Function nodes to acquire the data from both the user's mouse and keyboard.

 

While the VI is running, the coordinates will appear on the front panel and the boolean indicators will light up when a mouse button is pressed. Also, when the user hits enter on the keyboard, a message box will appear.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Run the VI
  2. The coordinates will appear on the front panel, the boolean indicators will light up when a mouse button is pressed, and a message box will appear when the user hits Enter on the keyboard, .

 

Additional Information or References

 

VI Snippet

1.png

 

 

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

Chris Van Horn
Applications Engineer

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