LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mouse position?

In Visual Basic you can find out the position of the mouse-pointer.
How do you do that in LabVIEW 6i?

(It works if you use a picture-box (property node), but it could be
difficult to use a picture-box all over the VI)

Richard
0 Kudos
Message 1 of 10
(6,027 Views)
Richard,

I've seen this done in a LV 6i demo. The developer had a DLL written
that returned the mouse position obtained form a windows API call. Sorry I
don't have this DLL otherwise I would send it. What you could do is search
the NI web site for a windows event utility. I have used one I found there
but can't find the original zip file I downloaded. I believe it was
something of the form winevent.zip. Try search words like "keyboard", even
though you are after the mouse position as that package contains both. If
you are still stuck, I can make a zip file of what I recall the original
file contained, then send it to you. Good luck.

Craig
"RICHARD PETTERSEN" wrote in message
news:lzwT5.130$Pe4.21716@juliett.dax.net...
>
In Visual Basic you can find out the position of the mouse-pointer.
> How do you do that in LabVIEW 6i?
>
> (It works if you use a picture-box (property node), but it could be
> difficult to use a picture-box all over the VI)
>
> Richard
>
>
0 Kudos
Message 2 of 10
(6,027 Views)
> In Visual Basic you can find out the position of the mouse-pointer.
> How do you do that in LabVIEW 6i?
>
There exist several Wndows tools (winutl32.llb). It includes a VI which
gives
you the cursor positions in screen coordinates.

Max
0 Kudos
Message 3 of 10
(6,027 Views)
Rich,

I found this link :

http://zone.ni.com/devzone/devzoneweb.nsf/opendoc?openagent&74DDE683A1AFF6988625683A000C0D73&cat=034E59A8530E09DF862568900018707A

with this description :

These VIs make calls to the Windows API for managing and controlling windows
(minimize, maximize, move, resize, rename, close, etc.); managing applications
(run application, quit application, print file, etc.); adding and removing
network resources; keyboard filtering; and system utilities (mouse cursor
position, windows path, screen resolution, system path, etc.). These VIs
are intended for use on 32-bit Windows platforms only

I hope this helps,
Jared

"RICHARD PETTERSEN" wrote:
>In Visual Basic you can find out the position of the mouse-pointer.>How
d
o you do that in LabVIEW 6i?>>(It works if you use a picture-box (property
node), but it could be>difficult to use a picture-box all over the VI)>>Richard>>
Message 4 of 10
(6,027 Views)
Try our vi-library at www.air.nl Look for GetMousePos.vi

Regards,

Wiebe Walstra.

--
AIR technical Automation
www.air.nl
"RICHARD PETTERSEN" wrote in message
news:lzwT5.130$Pe4.21716@juliett.dax.net...
In Visual Basic you can find out the position of the mouse-pointer.
How do you do that in LabVIEW 6i?

(It works if you use a picture-box (property node), but it could be
difficult to use a picture-box all over the VI)

Richard
0 Kudos
Message 5 of 10
(6,027 Views)
Use win32 utilities doesn't solve the problem completely. Because the win32 utility gives you the coordinates with respect to the entire screen. If you want to hard-code your object location, due to different windows resolution, different VI window size (including user customized sizes), it's mostly impossible. But there is one way out which includes some calculation in the begining, which you retrieve the windows resolution, then the VI windows size, then you can calculate with respect to all those, where you object will be. That will also allow you to programmatically locate the desired object. The truthfullness in this idea has not been tested. Just a thought on it.
Message 6 of 10
(6,027 Views)
"CGM Engineering Inc." wrote:

> Use win32 utilities doesn't solve the problem completely. Because the
> win32 utility gives you the coordinates with respect to the entire
> screen. If you want to hard-code your object location, due to
> different windows resolution, different VI window size (including user
> customized sizes), it's mostly impossible. But there is one way out
> which includes some calculation in the begining, which you retrieve
> the windows resolution, then the VI windows size, then you can
> calculate with respect to all those, where you object will be. That
> will also allow you to programmatically locate the desired object. The
> truthfullness in this idea has not been tested. Just a thought on it.

You forgot the frame size, and it's varie
s with the VI setting.
To convert between screen coordinate and client coordinate
(with respect to the front panel client area), you can use
"Screen to Client.vi" & "Client to Screen.vi". Download
G Toolbox at:

http://george-zou.siancity.com

To convert between client coordinate and LabVIEW coordinate,
use following formula:

attribute.x = Client.x + FrontPanel.Origin.x
attribute.y = Client.y + FrontPanel.Origin.y


George
0 Kudos
Message 7 of 10
(6,027 Views)
If the user moves the panel around the screen, or scrolls the panel
using scrollbars, it can be difficult to track.

I ended up using a relative system:
Find the position of a reference object on your panel relative to top
left corner of screen (strictly, of the primary workspace)
Find the position of the interesting object relative to the reference
object
Find the position of the mouse relative to top left corner of screen
Use these to decide whether mouse is over interesting object.

All that to implement the onmouseover command! (Or similar in
JavaScript?)

Used all that to implement a menu application which was used for 2
years.

Mark

George Zou wrote:
>
> "CGM Engineering Inc." wrote:
>
> > Use win32 utilities doesn't solve the proble
m completely. Because the
> > win32 utility gives you the coordinates with respect to the entire
> > screen. If you want to hard-code your object location, due to
> > different windows resolution, different VI window size (including user
> > customized sizes), it's mostly impossible. But there is one way out
> > which includes some calculation in the begining, which you retrieve
> > the windows resolution, then the VI windows size, then you can
> > calculate with respect to all those, where you object will be. That
> > will also allow you to programmatically locate the desired object. The
> > truthfullness in this idea has not been tested. Just a thought on it.
>
> You forgot the frame size, and it's varies with the VI setting.
> To convert between screen coordinate and client coordinate
> (with respect to the front panel client area), you can use
> "Screen to Client.vi" & "Client to Screen.vi". Download
> G Toolbox at:
>
> http://george-zou.siancity.com
>
> To convert between
client coordinate and LabVIEW coordinate,
> use following formula:
>
> attribute.x = Client.x + FrontPanel.Origin.x
> attribute.y = Client.y + FrontPanel.Origin.y
0 Kudos
Message 8 of 10
(6,027 Views)
Mark Hanning-Lee wrote:

> If the user moves the panel around the screen, or scrolls the panel
> using scrollbars, it can be difficult to track.

With Win32API, conversion can be done easily (no matter where you move
the window to, regardless the position of your scrollbar). You don't have
to do the track yourself.
Coordinate convert llb can be downloaded from my web site as
I mentioned in my previous post.

George
0 Kudos
Message 9 of 10
(6,027 Views)
The link no longer works.. Any chance of posting the convert.llb as an attachment?
0 Kudos
Message 10 of 10
(6,027 Views)