SkillAgentSearch skills...

Open.WinKeyboardHook

A simple and easy-to-use .NET managed wrapper for Low Level Keyboard hooking.

Install / Use

/learn @lontivero/Open.WinKeyboardHook
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Build status NuGet version

Open.WinKeyboardHook

A simple and easy-to-use .NET managed wrapper for Low Level Keyboard hooking.

Goals

The main goal is to abstract away the complexities inherit to intercept and translate global keystrokes (KeyDown / KeyUp / KeyPress) in the system.

Usage

public partial class TestForm : Form
{
    private readonly IKeyboardInterceptor _interceptor;

    public TestForm()
    {
        InitializeComponent();

        // Everytime a key is press we want to display it in a TextBox
        _interceptor = new KeyboardInterceptor();
        _interceptor.KeyPress += (sender, args) => txt.Text += args.KeyChar;
    }

    // Start and Stop capturing keystroks
    private void BtnClick(object sender, EventArgs e)
    {
        if(!_capturing)
        {
            _interceptor.StartCapturing();
            btn.Text = "Stop";
            btn.BackColor = Color.Red;
        }
        else
        {
            _interceptor.StopCapturing();
            btn.Text = "Start";
            btn.BackColor = Color.Lime;
        }
        _capturing = !_capturing;
    }
}

Real world example

Open.WinKeyboardHook is been used as the key component in KeyPadawan project, a useful tool for presentation and screencasts that allow to display the shortcuts that a presenter uses.

Development

Open.WinKeyboardHook is been developed by Lucas Ontivero (@lontivero). You are welcome to contribute code. You can send code both as a patch or a GitHub pull request.

View on GitHub
GitHub Stars22
CategoryDevelopment
Updated1y ago
Forks10

Languages

C#

Security Score

80/100

Audited on Feb 6, 2025

No findings