SharpHook.Reactive 3.0.0

.NET 5.0 .NET Core 3.1 .NET Standard 2.0 .NET Framework 4.6.1
Install-Package SharpHook.Reactive -Version 3.0.0
dotnet add package SharpHook.Reactive --version 3.0.0
<PackageReference Include="SharpHook.Reactive" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SharpHook.Reactive --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SharpHook.Reactive, 3.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install SharpHook.Reactive as a Cake Addin
#addin nuget:?package=SharpHook.Reactive&version=3.0.0

// Install SharpHook.Reactive as a Cake Tool
#tool nuget:?package=SharpHook.Reactive&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SharpHook.Reactive

SharpHook provides a cross-platform global keyboard and mouse hook for .NET, and the ability to simulate input events. It is a thin wrapper of libuiohook and provides direct access to its features as well as higher-level types to work with it.

If you're using Rx.NET, you can use the SharpHook.Reactive package to integrate SharpHook with Rx.NET.

Usage

Basic Usage

Refer to the SharpHook package for the basic usage guidelines.

Reactive Global Hooks

SharpHook.Reactive provides the IReactiveGlobalHook interface along with a default implementation and an adapter which you can use to use to control the hook and subscribe to its observables. Here's a basic example:

using SharpHook.Reactive;

// ...

var hook = new SimpleReactiveGlobalHook();

hook.HookEnabled.Subscribe(OnHookEnabled);
hook.HookDisabled.Subscribe(OnHookDisabled);

hook.KeyTyped.Subscribe(OnKeyTyped);
hook.KeyPressed.Subscribe(OnKeyPressed);
hook.KeyReleased.Subscribe(OnKeyReleased);

hook.MouseClicked.Subscribe(OnMouseClicked);
hook.MousePressed.Subscribe(OnMousePressed);
hook.MouseReleased.Subscribe(OnMouseReleased);

hook.MouseMoved
    .Throttle(TimeSpan.FromSeconds(0.5))
    .Subscribe(OnMouseMoved);

hook.MouseDragged
    .Throttle(TimeSpan.FromSeconds(0.5))
    .Subscribe(OnMouseDragged);

hook.MouseWheel.Subscribe(OnMouseWheel);

hook.Run();
// or
hook.RunAsync().Subscribe();

Reactive global hooks are basically the same as the default global hooks and the same rules apply to them.

SharpHook.Reactive provides two implementations of IReactiveGlobalHook:

  • SimpleReactiveGlobalHook. Since we are dealing with observables, it's up to you to decide when and where to handle the events through schedulers.

  • ReactiveGlobalHookAdapter adapts an IGlobalHook to IReactiveGlobalHook. All subscriptions and changes are propagated to the adapted hook.

Logging

SharpHook.Reactive contains the IReactiveLogSource and ReactiveLogSourceAdapter so you can use them in a more reactive way than ILogSource and LogSource:

using SharpHook.Logging;
using SharpHook.Reactive.Logging;

// ...

var logSource = LogSource.Register();
var reactiveLogSource = new ReactiveLogSourceAdapter(logSource);
reactiveLogSource.MessageLogged.Subscribe(this.OnMessageLogged);

Icon

Icon made by Freepik from www.flaticon.com.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 129 3/27/2022
2.0.0 221 2/4/2022
1.1.0 628 12/4/2021
1.0.1 461 11/21/2021
1.0.0 211 11/8/2021
1.0.0-preview.4 78 11/6/2021
1.0.0-preview.3 96 11/1/2021
1.0.0-preview.2 79 10/26/2021
1.0.0-preview.1 71 10/26/2021