This repository has been archived on 2023-05-28. You can view files and clone it, but cannot push or open issues/pull-requests.
SkyHook-Native/README.md

66 lines
1.5 KiB
Markdown
Raw Normal View History

2022-11-03 18:58:31 +09:00
# SkyHook-Native
2022-11-05 11:37:27 +09:00
2022-11-06 23:33:45 +09:00
Dynamic library of SkyHook for use with other languages.
2022-11-05 11:37:27 +09:00
2022-11-06 10:48:46 +09:00
## Usage
2022-11-06 23:33:45 +09:00
The following examples are all in C#.
2022-11-06 10:48:46 +09:00
### Functions
2022-11-06 23:33:45 +09:00
The extern functions that you should run are simple.
2022-11-06 10:48:46 +09:00
2022-11-07 13:28:36 +09:00
There are just two; [`start_hook`](#start_hook) and [`stop_hook`](#stop_hook).
2022-11-06 23:33:45 +09:00
### `start_hook`
2022-11-06 10:48:46 +09:00
```cs
2022-11-06 23:33:45 +09:00
// Here, we assign a callback along with starting a hook.
// The NativeEvent type is declared below "Types" header.
2022-11-06 12:23:25 +09:00
public static delegate void HookCallback(NativeEvent ev);
2022-11-06 10:48:46 +09:00
2022-11-06 23:33:45 +09:00
// Here, we have an extern method to invoke.
2022-11-06 10:48:46 +09:00
[DllImport("skyhook", EntryPoint = "start_hook")]
public static extern void StartHook(HookCallback callback);
```
2022-11-06 23:33:45 +09:00
### `stop_hook`
2022-11-06 10:48:46 +09:00
```cs
2022-11-06 23:33:45 +09:00
// No additional information required to provide when stopping the hook.
2022-11-06 10:48:46 +09:00
[DllImport("skyhook", EntryPoint = "stop_hook")]
public static extern void StopHook();
```
### Types
2022-11-06 23:33:45 +09:00
### `NativeEventType`
2022-11-06 10:48:46 +09:00
```cs
public enum NativeEventType {
2022-11-06 23:33:45 +09:00
KeyPressed,
KeyReleased
2022-11-06 10:48:46 +09:00
}
```
2022-11-06 23:33:45 +09:00
### `NativeEvent`
2022-11-06 10:48:46 +09:00
```cs
[StructLayout(LayoutKind.Sequential)]
public struct NativeEvent
{
2022-11-06 23:33:45 +09:00
public readonly ulong Time; // This is the key state update time.
public readonly NativeEventType Type; // Whether the key is up or down.
public readonly ushort Label; // Unified label for keys, such as ESC or F11.
public readonly ushort Key; // Actual key code from native level.
2022-11-06 10:48:46 +09:00
}
```
2022-11-05 11:37:27 +09:00
## Development
```sh
git clone https://git.pikokr.dev/SkyHook/SkyHook-Native #Clone
```
2022-11-06 23:33:45 +09:00
To build, just run [`build.sh`](build.sh) on Linux of MacOS, [`build.ps1`](build.ps1) on Windows.