LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

detect mouse click on non labview window

Hello,

 

Does someone could help me to know where the mouse is clicked in non labview window

 

i started using user32.dll

 

i can indicate which window i want to use, i can swith to it,  now i 'm little stuck with which function to use

to detect where i click (left but) the mouse on this window

 

i need to recover cordinates + left down butt event to start another vi from this point

an idea ?

 

Tinnitus

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 1 of 8
(3,738 Views)

You said you started using user32.dll. How far did you get? What you are looking to do basically involves using global hooks via the Windows API. For this, you'd need to write your own DLL to handle the callbacks. If you Google you should be able to find examples.

0 Kudos
Message 2 of 8
(3,724 Views)

So,

 

Labview has input functions (see 'initialize mouse' and 'acquire input data'). These can get you the state of the mouse if you loop over them continuously, regardless of where the mouse is or over what window the mouse is operating.

 

I don't think you have access to the messages generated by the mouse directly though, as those are normally only shared with the window over which the event occurs. I'm not sure going into the windows api gets you more information than what is available with the labview input functions.

 

Of course, if you have total control over the non-labview window (i.e you are writing the code for it), then you can handle the mouse events in that window. See the windows mouse api and specifically handling mouse messages in the windows procedure function.

 

http://msdn.microsoft.com/en-us/library/windows/desktop/ms645533(v=VS.85).aspx

Message 3 of 8
(3,721 Views)

@majoris wrote:

So,

 

Labview has input functions (see 'initialize mouse' and 'acquire input data'). These can get you the state of the mouse if you loop over them continuously, regardless of where the mouse is or over what window the mouse is operating.



Oh, yeah. Keep forgetting about those. My brain has developed a leak. Thanks for the reminder. Smiley Wink

0 Kudos
Message 4 of 8
(3,715 Views)

 

Hello,

 

yes i know about the mouse input palette but is not sufficient to do what i need

 

i see that i have to use user32.dll functions but which ones

 

i heard about SetWindowsHookEx ...

 

Regards

 

Tinnitus

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 5 of 8
(3,699 Views)

The input functions give you the corrdinates + mouse button state which what you said you wanted. I assume there is an additional requirement you didn't mention?

Message 6 of 8
(3,689 Views)

Hello,

 

yes, i just tried on my home computer  i don't know why button status was not visible on my office pc 

i will check tomorrow.

 

A thing ,  here we are forced to use a polling method  , i would have prefered to record left click  as an event

 

 

Regards

 

Tinnitus

 

 

 

 

 

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 7 of 8
(3,680 Views)

For events you would need to deal with callbacks from the Windows API. For this you will need to create a wrapper DLL. I'd suggest taking a look at the examples in the Windows Message Queue Library. That library contains source code for the DLL that you can take a look at.

0 Kudos
Message 8 of 8
(3,668 Views)