LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mouse Move Event Outside vi

Vasanth,

Again, you need mouse hook. In the other words you must create DLL, where you should register your hook by calling following function:

     hook = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)msghook, hInst, 0);

Application instance you will get from DllMain something like that:

BOOL APIENTRY DllMain( HINSTANCE hInstance,  DWORD  Reason,  LPVOID Reserved)

{
 switch(Reason)
     case DLL_PROCESS_ATTACH:
  hInst = hInstance;

...

So, now every time when mouse moved your hook callback function will be called:

static LRESULT CALLBACK msghook(UINT nCode, WPARAM wParam, LPARAM lParam)
{
    LPMSG msg = (LPMSG)lParam;
    if(msg->message == WM_MOUSEMOVE || msg->message == WM_NCMOUSEMOVE)
   //Do something for inform LabVIEW about movement, for example set LabVIEW occurence
    return CallNextHookEx(hook, nCode, wParam, lParam);
} // msghook

Do not forget to remove your hook when application will be finished:

UnhookWindowsHookEx(hook);

Its a quite terrible to debug this, but in general it should work.

with best regards,

Andrey.

 

0 Kudos
Message 11 of 15
(919 Views)

Andrey,

         Thanks. Let me try this.

Thanks,

Vasanth.

Ya Ya
0 Kudos
Message 12 of 15
(912 Views)

Andrey,

          I dont have a visual studio installed in my pc. Can you please provide the functions you have given as dlls?

Thanks,

Vasanth.

Ya Ya
0 Kudos
Message 13 of 15
(898 Views)
There are functions:
 
 
If you haven't MSVC, then you can use any freeware C compiler, which able to build DLL for Win.
Also may be possible to create DLL in LabVIEW, but not sure about callback...
 
Here is good starting point:
 
Andrey.
 
0 Kudos
Message 14 of 15
(891 Views)

Andrey,

         Thanks. I will look into it.

Thanks,

Vasanth.

Ya Ya
0 Kudos
Message 15 of 15
(878 Views)