TripleG3.User32 8.0.4

dotnet add package TripleG3.User32 --version 8.0.4                
NuGet\Install-Package TripleG3.User32 -Version 8.0.4                
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="TripleG3.User32" Version="8.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TripleG3.User32 --version 8.0.4                
#r "nuget: TripleG3.User32, 8.0.4"                
#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.
// Install TripleG3.User32 as a Cake Addin
#addin nuget:?package=TripleG3.User32&version=8.0.4

// Install TripleG3.User32 as a Cake Tool
#tool nuget:?package=TripleG3.User32&version=8.0.4                

TripleG3.User32

Project for hooking libraries in Windows applications such as keyboard and mouse.

Example hooking / listening to the keyboard:

public class Keyboard
{
    private readonly KeyHook keyHook;

    public Keyboard()
    {
        keyHook = new KeyHook();
        keyHook.KeyEvent += KeyHookKeyEvent;
    }

    public void Hook() => keyHook.Hook();
    public void UnHook() => keyHook.UnHook();

    private void KeyHookKeyEvent(object? sender, KeyEventArgs e)
    {
        // Arguments derived from KBDLLHOOKSTRUCT using SetWindowsHookExA hooking WH_KEYBOARD_LL and parsing KBDLLHOOKSTRUCTFlags
        // e.IsExtendedKey
        // e.IsInjected
        // e.IsAltDown
        // e.IsKeyUp
        // e.VirtualKeyCode
        // e.ScanCode
        // e.Time
        // e.ExtraInfo
        // and more
    }
}

More practical example injecting IKeyboardHook and properly disposing:

public sealed class KeyboardListener(IKeyboardHook keyboardHook) : IDisposable
{
    public event EventHandler<KeyboardHookEventArgs> KeyboardEvent = (sender, e) => { };

    public void Start()
    {
        keyboardHook.KeyEvent += KeyboardHookKeyEvent;
        keyboardHook.Hook();
    }

    public void Stop()
    {
        keyboardHook.UnHook();
        keyboardHook.KeyEvent -= KeyboardHookKeyEvent;
    }

    private void KeyboardHookKeyEvent(object? sender, KeyboardHookEventArgs e) => KeyEvent(this, e);

    public void Dispose()
    {
        Stop();
        GC.SuppressFinalize(this);
    }

    ~KeyboardListener() => Dispose();
}

Follow the examples for keyboard similarly for the mouse.

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible. 
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

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.4 119 1/21/2024
8.0.3 101 1/21/2024
8.0.1 100 1/21/2024
8.0.0 99 1/21/2024