Step 1:添加引用或在Nuget直接搜索【Kane.GlobalHook】;
Install-Package Kane.GlobalHook
Step 2:使用方法:
var keyboardHook = new KeyboardHook();
keyboardHook.KeyEvent += (sender,e) =>
{
//e为 KeyboardHookEventArgs
//事件
};
keyboardHook.Hook();//挂载键盘钩子
keyboardHook.Unhook();//卸载键盘钩子
var mouseHook = new MouseHook();
mouseHook.MouseEvent += (sender,e) =>
{
//e为 MouseHookEventArgs
//事件
};
mouseHook.Hook();//挂载鼠标钩子
mouseHook.Unhook();//卸载鼠标钩子