• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

How can I catch a MoseMove over annother app. Window ?


I want to catch the MouseMessages from annother applications window. SetCapture doesn´t catch the move messages. How can I do that ?
1 Solution
Roshan DavisCommented:
Hi AndersCarlsson,
       You have to set windows hook for mouse.

Create a dll, and write this code into it,
LoadTheDll from your application.

The code for setting up the hooks will look like this:

hhookMouse = SetWindowsHookEx(WH_MOUSE,
   (HOOKPROC) MouseFunc,  hInstance, 0);

…which will cause the following hook function to be called:

LRESULT CALLBACK MouseFunc(int nCode, WPARAM wParam, LPARAM lParam)
if ( nCode >= 0 )
         return 1;
   return(CallNextHookEx(hhookMouse, nCode, wParam, lParam));

Don't forget to unhook your hook before you exit by calling the following:


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now