WindowsHook 1.0.0
See the version list below for details.
dotnet add package WindowsHook --version 1.0.0
NuGet\Install-Package WindowsHook -Version 1.0.0
<PackageReference Include="WindowsHook" Version="1.0.0" />
paket add WindowsHook --version 1.0.0
#r "nuget: WindowsHook, 1.0.0"
// Install WindowsHook as a Cake Addin #addin nuget:?package=WindowsHook&version=1.0.0 // Install WindowsHook as a Cake Tool #tool nuget:?package=WindowsHook&version=1.0.0
WindowsHook
Based on MouseKeyHook by gmamaladze . I made some changes to to support .Net 4.0+,.Net Core 3.0+, WinForm, WPF etc. To make this project not to depend on System.Windows.Forms, some codes are from Microsoft which files are under system.Windows.Forms. I changed original namepsace to System.Windows.Hook.
What it does?
This library allows you to tap keyboard and mouse, to detect and record their activity even when an application is inactive and runs in background.
Prerequisites
- Windows: .Net 4.0+,.Net Core 3.0+, Windows Desktop Apps(WinForm, WPF etc.)
Installation and sources
<pre> nuget install WindowsHook </pre>
Usage
private IKeyboardMouseEvents m_GlobalHook;
public void Subscribe()
{
// Note: for the application hook, use the Hook.AppEvents() instead
m_GlobalHook = Hook.GlobalEvents();
m_GlobalHook.MouseDownExt += GlobalHookMouseDownExt;
m_GlobalHook.KeyPress += GlobalHookKeyPress;
}
private void GlobalHookKeyPress(object sender, KeyPressEventArgs e)
{
Console.WriteLine("KeyPress: \t{0}", e.KeyChar);
}
private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
{
Console.WriteLine("MouseDown: \t{0}; \t System Timestamp: \t{1}", e.Button, e.Timestamp);
// uncommenting the following line will suppress the middle mouse button click
// if (e.Buttons == MouseButtons.Middle) { e.Handled = true; }
}
public void Unsubscribe()
{
m_GlobalHook.MouseDownExt -= GlobalHookMouseDownExt;
m_GlobalHook.KeyPress -= GlobalHookKeyPress;
//It is recommened to dispose it
m_GlobalHook.Dispose();
}
(also have a look at the Demo app included with the source)
How it works?
This library attaches to windows global hooks, tracks keyboard and mouse clicks and movement,please note this don't support common .Net events with KeyEventArgs and MouseEventArgs. this is the difference with WindowsHook project. But you can still easily retrieve any information you need:
- Mouse coordinates
- Mouse buttons clicked
- Mouse drag actions
- Mouse wheel scrolls
- Key presses and releases
- Special key states
Additionally, there are MouseEventExtArgs
and KeyEventExtArgs
which provide further options:
- Input suppression
- Timestamp
- IsMouseDown/Up
- IsKeyDown/Up.
Quick contributing guide
- Fork and clone locally
- Create a topic specific branch. Add some nice feature.
- Send a Pull Request to spread the fun!
License
The MIT license see: LICENSE.txt
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp3.0 is compatible. netcoreapp3.1 was computed. |
.NET Framework | net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETCoreApp 3.0
- No dependencies.
-
.NETFramework 4.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on WindowsHook:
Package | Downloads |
---|---|
TAO3
TAO3 is a .NET Interactive extension for writing data transformation quickly. |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on WindowsHook:
Repository | Stars |
---|---|
DeadlyCrush/DeadlyTrade
DeadlyTrade for Path Of Exile - (Overhaul Version) Trade Notification, Functional Overlay, Flask&Skill Timer, Map&Region Information, Real-Time Ninja Currency, Act Helper when Leveling and other useful functions.
|
|
hawkeye-stan/msfs-popout-panel-manager
Pop out panel manager for MSFS 2020
|