Skip to content

Commit 2f210cd

Browse files
Update the package readmes
1 parent 459b404 commit 2f210cd

File tree

3 files changed

+99
-2
lines changed

3 files changed

+99
-2
lines changed

SharpHook.R3/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# SharpHook.R3
2+
3+
SharpHook provides a cross-platform global keyboard and mouse hook, event simulation, and text entry simulation for
4+
.NET. It is a wrapper of [libuiohook](https://github.com/TolikPylypchuk/libuiohook) and provides direct access to its
5+
features as well as higher-level types to work with it.
6+
7+
If you're using [R3](https://github.com/Cysharp/R3), you can use the SharpHook.R3 package to integrate SharpHook with
8+
R3.
9+
10+
## Usage
11+
12+
### Basic Usage
13+
14+
Refer to the [SharpHook](https://www.nuget.org/packages/SharpHook) package for the basic usage guidelines.
15+
16+
### R3 Global Hooks
17+
18+
SharpHook.R3 provides the `IR3GlobalHook` interface along with a default implementation and an adapter which you can use
19+
to use to control the global hook and subscribe to its observables. Here's a basic example:
20+
21+
```c#
22+
using SharpHook.R3;
23+
24+
// ...
25+
26+
var hook = new SimpleR3GlobalHook();
27+
28+
hook.HookEnabled.Subscribe(OnHookEnabled);
29+
hook.HookDisabled.Subscribe(OnHookDisabled);
30+
31+
hook.KeyTyped.Subscribe(OnKeyTyped);
32+
hook.KeyPressed.Subscribe(OnKeyPressed);
33+
hook.KeyReleased.Subscribe(OnKeyReleased);
34+
35+
hook.MouseClicked.Subscribe(OnMouseClicked);
36+
hook.MousePressed.Subscribe(OnMousePressed);
37+
hook.MouseReleased.Subscribe(OnMouseReleased);
38+
39+
hook.MouseMoved
40+
.Debouce(TimeSpan.FromSeconds(0.5))
41+
.Subscribe(OnMouseMoved);
42+
43+
hook.MouseDragged
44+
.Debouce(TimeSpan.FromSeconds(0.5))
45+
.Subscribe(OnMouseDragged);
46+
47+
hook.MouseWheel.Subscribe(OnMouseWheel);
48+
49+
hook.Run();
50+
// or
51+
await hook.RunAsync();
52+
```
53+
54+
R3 global hooks are basically the same as the default global hooks and the same rules apply to them.
55+
56+
SharpHook.R3 provides two implementations of `IR3GlobalHook`:
57+
58+
- `SharpHook.R3.SimpleR3GlobalHook`. Since we're dealing with observables, it's up to you to decide when and where to
59+
handle the events through time providers. A default time provider can be specified for all observables.
60+
61+
- `SharpHook.R3.R3GlobalHookAdapter` adapts an `IGlobalHook` to `IR3GlobalHook`. All subscriptions and changes are
62+
propagated to the adapted hook. There is no default adapter from `IR3GlobalHook` to `IGlobalHook`. A default time
63+
provider can be specified for all observables.
64+
65+
### Logging
66+
67+
SharpHook.R3 contains `IR3LogSource` and `R3LogSourceAdapter` so you can use them in a more reactive way:
68+
69+
```c#
70+
using SharpHook.Logging;
71+
using SharpHook.R3.Logging;
72+
73+
// ...
74+
75+
var logSource = LogSource.RegisterOrGet();
76+
var r3LogSource = new R3LogSourceAdapter(logSource);
77+
r3LogSource.MessageLogged.Subscribe(this.OnMessageLogged);
78+
```
79+
80+
### Rx.NET Integration
81+
82+
As an alternative, SharpHook also provides integration with [Rx.NET](https://github.com/dotnet/reactive) in the
83+
[SharpHook.Reactive](https://www.nuget.org/packages/SharpHook.Reactive) package.
84+
85+
## Icon
86+
87+
Icon made by [Freepik](https://www.freepik.com) from [www.flaticon.com](https://www.flaticon.com).

SharpHook.Reactive/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ SharpHook provides a cross-platform global keyboard and mouse hook, event simula
44
.NET. It is a wrapper of [libuiohook](https://github.com/TolikPylypchuk/libuiohook) and provides direct access to its
55
features as well as higher-level types to work with it.
66

7-
If you're using Rx.NET, you can use the SharpHook.Reactive package to integrate SharpHook with Rx.NET.
7+
If you're using [Rx.NET](https://github.com/dotnet/reactive), you can use the SharpHook.Reactive package to integrate
8+
SharpHook with Rx.NET.
89

910
## Usage
1011

@@ -77,6 +78,11 @@ var reactiveLogSource = new ReactiveLogSourceAdapter(logSource);
7778
reactiveLogSource.MessageLogged.Subscribe(this.OnMessageLogged);
7879
```
7980

81+
### R3 Integration
82+
83+
As an alternative, SharpHook also provides integration with [R3](https://github.com/Cysharp/R3) in the
84+
[SharpHook.R3](https://www.nuget.org/packages/SharpHook.R3) package.
85+
8086
## Icon
8187

8288
Icon made by [Freepik](https://www.freepik.com) from [www.flaticon.com](https://www.flaticon.com).

SharpHook/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ the events. It also keeps a reference to a running global hook so that it's not
116116

117117
### Reactive Global Hooks
118118

119-
Use the [SharpHook.Reactive](https://www.nuget.org/packages/SharpHook.Reactive) package for reactive global hooks.
119+
Use the [SharpHook.Reactive](https://www.nuget.org/packages/SharpHook.Reactive) package for reactive global hooks with
120+
[Rx.NET](https://github.com/dotnet/reactive) integration.
121+
122+
Use the [SharpHook.R3](https://www.nuget.org/packages/SharpHook.R3) package for reactive global hooks with
123+
[R3](https://github.com/Cysharp/R3) integration.
120124

121125
### Event Simulation
122126

0 commit comments

Comments
 (0)