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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Confine mouse movement within boundary

Solved!
Go to solution

Hi,

 

Can anyone advise me how I can confine mouse movement within an area/pane?

I have added a vertical container to split into two panes. When running the application, I would like to restrict user mouse movement to the left pane.

 

-Sable

 

 

0 Kudos
Message 1 of 20
(3,489 Views)

I don't think you can,or should.

 

How would the user move outside of the VI windows if they wanted to do something else with like open another app, shutdown the PC?

Message 2 of 20
(3,472 Views)

I agree with RavensFan. Limiting the movement of the mouse cursor is not a good idea.

 

However, if you still want to do it, here is a VI (in LabVIEW 2016) that I created to test  how to programmatically move the mouse cursor. My goal was to keep the mouse cursor outside of an area (the bait). The VI uses the SetCursorPos function of User32.dll that is available only on Windows in C:\Windows\System32.

 

You can stop the VI by pressing any key.

 

Click-bait_BD.png

Marc Dubois
Message 3 of 20
(3,469 Views)
0 Kudos
Message 4 of 20
(3,452 Views)

My intention is to confine the mouse cursor within a boundary only when the user starts to draw a ROI Line on an IMAQ image.

Once the user completes the drawing, I would like to undo the confinement.

 

ClipCursor works well.

I've attached the example code in LabVIEW 2013.

 

Question, how do I undo the confinement via LabVIEW back to it's original?

 

- Sable

Download All
0 Kudos
Message 5 of 20
(3,444 Views)

Call ClipCursor again with a NULL pointer and it should release.

 

0xDEAD

0 Kudos
Message 6 of 20
(3,422 Views)

Like this?

 

ClipCursor2.PNG

If yes, then it doesn't release it. It just confines the mouse at location 0,0. Top left of the screen.

0 Kudos
Message 7 of 20
(3,401 Views)

Before you start clipping, use GetClipCursor() to read to get the current clip region and store this value.  When you are finished, pass this value to ClipCursor() to restore it.  That is the preferred way to handle this type of operation.  

Message 8 of 20
(3,393 Views)

@Sable wrote:

Like this?

 

ClipCursor2.PNG

If yes, then it doesn't release it. It just confines the mouse at location 0,0. Top left of the screen.


No, not like that.

 

You have to make a 2nd clfn, with the input configured as value. Then wire a 0 to it.

 

A null pointer isn't the same as a cluster with zero's.

0 Kudos
Message 9 of 20
(3,386 Views)

Like this? (please refer to the attached vi done on LabVIEW 2013).

0 Kudos
Message 10 of 20
(3,375 Views)