DeftSharp.Windows.Input 0.11.0

dotnet add package DeftSharp.Windows.Input --version 0.11.0
                    
NuGet\Install-Package DeftSharp.Windows.Input -Version 0.11.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DeftSharp.Windows.Input" Version="0.11.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DeftSharp.Windows.Input" Version="0.11.0" />
                    
Directory.Packages.props
<PackageReference Include="DeftSharp.Windows.Input" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DeftSharp.Windows.Input --version 0.11.0
                    
#r "nuget: DeftSharp.Windows.Input, 0.11.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DeftSharp.Windows.Input@0.11.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DeftSharp.Windows.Input&version=0.11.0
                    
Install as a Cake Addin
#tool nuget:?package=DeftSharp.Windows.Input&version=0.11.0
                    
Install as a Cake Tool

DeftSharp.Windows.Input

A powerful .NET library designed to control and manage the keyboard and mouse in the Windows OS. It is intended for use in various UI frameworks such as WPF, WinUI, Avalonia, and MAUI, providing a universal solution for all types of Windows applications.

The library offers a wide range of features including event subscriptions, bindings, preventing input events, device information and a lot of other things. It also provides flexible custom interceptors, allowing users to define their own logic.

Main Features

  • Subscribe to global keyboard and mouse events
  • Simulation of input from the code
  • Prevent specific input events
  • Change key bindings
  • Custom interceptors
  • Device information

Examples

Simple key subscription

You can subscribe to global keyboard events. Including their sequence and combination.

var keyboardListener = new KeyboardListener();

// Subscription for each click
keyboardListener.Subscribe(Key.Space, () => Trace.WriteLine($"The Space was pressed"));

// One-time subscription
keyboardListener.SubscribeOnce(Key.Space, key => Trace.WriteLine($"The {key} was pressed"));

// Subscription to the combination
keyboardListener.SubscribeCombination([Key.LeftShift, Key.W], () =>
    Trace.WriteLine($"The Shift + W was pressed"));

Input control from the code

You can simulate the operation of your keyboard and mouse by calling different input actions.

var keyboard = new KeyboardManipulator();
var mouse = new MouseManipulator();

keyboard.Press(Key.Escape);
keyboard.Press(Key.LeftCtrl, Key.V);

mouse.Click();
mouse.DoubleClick();
mouse.Scroll(150);

Prevent input events

You can prevent input events by default or with some condition.

var keyboard = new KeyboardManipulator();
var mouse = new MouseManipulator();

// Each press of this button will be ignored
keyboard.Prevent(Key.Delete);

// Prevent with condition
keyboard.Prevent(Key.Escape, () =>
{
   var currentTime = DateTime.Now;

   return currentTime.Minute > 30;
});

// Prevent mouse scroll
mouse.Prevent(MousePreventOption.Scroll);

Subscription to mouse move and get current coordinates

You can track mouse coordinates in real-time.

var mouseListener = new MouseListener();

mouseListener.Subscribe(MouseEvent.Move, () =>
     Label.Text = $"X: {mouseListener.Position.X} Y: {mouseListener.Position.Y}");

Requirements

  • .NET 8.0 for Windows
  • Any UI framework (WPF, WinUI, MAUI, Avalonia)
Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on DeftSharp.Windows.Input:

Repository Stars
insomniachi/FluentFin
Version Downloads Last Updated
0.11.0 507 10/12/2026
0.10.0 1,306 8/30/2024
0.9.0 389 4/16/2024
0.8.2 272 4/10/2024
0.8.1 250 4/7/2024
0.8.0 248 4/7/2024
0.7.1 270 4/1/2024
0.7.0 268 3/28/2024
0.6.0 267 3/24/2024
0.5.0 262 3/21/2024
0.4.0 265 3/18/2024
0.3.0 279 3/10/2024
0.2.0 272 3/6/2024
0.1.0 295 3/4/2024