代码拉取完成,页面将自动刷新
This is an extension to globalmousekeyhook and InputSimulator library which allows you to tap keyboard and mouse, to detect and record their activity event when an application is inactive and runs in background.The Windows Input Simulator provides a simple .NET(C#) interface to simulate Keyboard or Mouse input using the Win32 SendInput method.
nuget install KeyMouseHook
private readonly KeyMouseFactory eventHookFactory = new KeyMouseFactory(HookType.GlobalEvents);
private readonly KeyboardWatcher keyboardWatcher;
private readonly MouseWatcher mouseWatcher;
private List<MouseKeyEvent> _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<MacroEvent>();
keyboardWatcher.Start(events);
mouseWatcher.Start(events);
}
private void StopWatch()
{
keyboardWatcher.Stop();
mouseWatcher.Stop();
}
private void Playback()
{
var sim = new InputSimulator();
sim.PlayBack(_macroEvents);
}
keyboardWatcher = eventHookFactory.GetKeyboardWatcher().Disable(MacroEventType.KeyDown | MacroEventType.KeyUp).Enable(MacroEventType.KeyPress);
mouseWatcher = eventHookFactory.GetMouseWatcher().Enable(MacroEventType.MouseDoubleClick | MacroEventType.MouseDragStarted).Disable(MacroEventType.MouseDragFinished | MacroEventType.MouseMove);
var sim = new InputSimulator().Enable(MacroEventType.MouseDoubleClick | MacroEventType.KeyPress).Disable(MacroEventType.MouseMove | MacroEventType.KeyDown | MacroEventType.KeyUp);
(also have a look at the Demo app included with the source)
The MIT license see: LICENSE
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。