Search code examples
c#focusevent-handlingmouseclick-event

How to make an application that can capture all click when you press the Enter key, but in my WinForm as well?


i try to develop an application who make a screenshot all mouseclick and when i hit the key "enter" for make a tutorial, but i don't see how capture this events where they are outside of my application. How i can do that ???


Solution

  • use this project "Processing Global Mouse and Keyboard Hooks in C#". I used it before and I personally always recommend it.

    How to use it:

    add reference tot the Gma.UserActivityMonitor dll to your project.

    using Gma.UserActivityMonitor.GlobalEventProvider;
    
    _globalEventProvider1 = new Gma.UserActivityMonitor.GlobalEventProvider();
    
    this._globalEventProvider1.KeyDown += HookKeyDown;//to listen to key down
    this._globalEventProvider1.KeyUp += HookKeyUp;//to listen to key down                
    this.globalEventProvider1.MouseDown += HookMouseDown;//to listen to mouse down 
    this.globalEventProvider1.MouseUp += HookMouseUp;//to listen to mouse up 
    
    //and a lot more...