To download NI software, including the products shown below, visit ni.com/downloads.
Overview
Specify the mouse position considering the window bounds as reference.
Description
You can use the event structure in LabVIEW to monitor the position of the mouse on the front panel. This can be useful in determining subsequent programming operations. We are simply using the "Mouse Move" event under <Pane>. By using an event, we are reading asynchronously. This is a major advantage over polling methods.
Requirements
LabVIEW 2012 or compatible
Steps to Implement or Execute Code
1. Run the VI
2. Move the mouse through the front panel
3. Finish execution with the Stop button
Additional Information or References
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Hi, may i ask that how to create the mouse move event under <This VI>? I can't see it, my option just only have "Mouse Enter" and "Mouse Leave" only. Is there any other requirement ? I'm using LabVIEW 2011
Hi Jellyfish,
I believe the "Mouse Move" event used in this example is actually specific to the Front Panel Pane, not the VI as a whole. So, the Event Source should be Panes, not <This VI>. The event will register, if the mouse is moved within the Front Panel.
-Matt
Hi Matt,
So is there any method to create the function same as this example ?
Hi,
Sorry for the delay - I was having trouble determining why we can open and run the VI with the <This VI>»Mouse Move event, but not recreate it. I found this Knowledge Base article, which indicates that the Mouse Move event was changed from a VI event to a Pane event moving from LabVIEW 7.x versions to LabVIEW 8.x versions.
In LabVIEW 8.x you cannot select the Mouse Down, Mouse Down?, Mouse Move, or Mouse Up events of the VI class in the Edit Events dialog box. Use the Mouse Down, Mouse Down?, Mouse Move, and Mouse Up events in the Pane class, respectively, instead.
So, this example was likely originally created in an older version of LabVIEW before the Mouse Move event was moved to a Pane event. That being said, the functionality is almost identical as a Pane event. Otherwise, you may want to look at this example (Move Mouse Without Event Structure), which acquires global mouse coordinates via a DLL.