C# 按键精灵类库 KeyMouseHook

码农软件 · 软件分类 · 常用工具包 · 2019-08-12 16:11:31

软件介绍

简介

这是一个基于globalmousekeyhook 和 InputSimulator 的类似于按键精灵的模拟键盘按键和鼠标点击操作的扩展类库。可以检测并记录键盘和鼠标的活动,你可以录制你的键鼠操作的记录并进行回放,可模拟键盘输入和鼠标点击操作。

环境

  • Windows: .Net Framework 4.0+

安装和源码

nuget install KeyMouseHook

使用

private readonly KeyMouseFactory eventHookFactory = new KeyMouseFactory(HookType.GlobalEvents);
private readonly KeyboardWatcher keyboardWatcher;
private readonly MouseWatcher mouseWatcher;
private List _mouseKeyEvents;

public FormMain()
{
   InitializeComponent();

   keyboardWatcher = eventHookFactory.GetKeyboardWatcher();
   keyboardWatcher.OnKeyboardInput += (s, e) =>
   {
	if (_mouseKeyEvents != null)
	    _mouseKeyEvents.Add(e);
   };

   mouseWatcher = eventHookFactory.GetMouseWatcher();
   mouseWatcher.OnMouseInput += (s, e) =>
   {
	if (_mouseKeyEvents != null)
	    _mouseKeyEvents.Add(e);
   };
}

private void StartWatch(IKeyboardMouseEvents events = null)
{
    _macroEvents = new List();
    keyboardWatcher.Start(events);
    mouseWatcher.Start(events);
}

private void StopWatch()
{
   keyboardWatcher.Stop();
   mouseWatcher.Stop();
}

private void Playback()
{
   var sim = new InputSimulator();
   //var sim = new KeyMouseSimulator();
   sim.PlayBack(_macroEvents);
}

(源码里包含更详细的示例)

界面

c#(winform)模拟键盘按键和鼠标点击操作类库

鸣谢

贡献代码

  • Fork并克隆到本机

  • 创建一个分支并添加你的代码

  • 发送一个Pull Request

License

The MIT license see: LICENSE

本文地址:https://www.codercto.com/soft/d/12213.html

The Elements of Statistical Learning

The Elements of Statistical Learning

Trevor Hastie、Robert Tibshirani、Jerome Friedman / Springer / 2009-10-1 / GBP 62.99

During the past decade there has been an explosion in computation and information technology. With it have come vast amounts of data in a variety of fields such as medicine, biology, finance, and mark......一起来看看 《The Elements of Statistical Learning》 这本书的介绍吧!

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具