Capture mouse event outside of form

kingtam2000

Active member
Joined
Jul 12, 2005
Messages
25
Programming Experience
1-3
I am creating a program to capture mouse clicks and record them to create a macro program, which could then replay what was recorded via the API mouse_event. However, I cannot find how to capture mouse clicks outside of the form, e.g. anywhere on the screen. Any help would be much appreciated! :)
 
I looked at the list of APIs but found it difficult to go through all 940 API functions. I have already tried using the API, GetAsyncKeyState, to continuously check if the mouse was pressed every 100 miliseconds, but it is not a very pratical method and does not always work.

Is there any way of receiving an event or some related action when the mouse is clicked? It is fairly easy to figure out where the mouse is after that.
 
I am speaking with only a vague connection between my brain and my fingers, but I think it might involve overriding the WndProc method and capturing the appropriate Windows message for a mouse click.
 
I had given it up, but I found this web page: http://support.microsoft.com/?scid=kb;en-us;319524&spid=8291&sid=89 , which gives a working example on how to create a mouse hook, but unfortunately, it only works for within the application. At the bottom of the web page, it states, "You cannot implement global hooks in Microsoft .NET Framework", which is what I think is needed to capture mouse clicks outside the application.
 
Back
Top