LostTech.EventHook 2.1.1

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

// Install LostTech.EventHook as a Cake Tool
#tool nuget:?package=LostTech.EventHook&version=2.1.1                

Windows User Action Hook

A one stop library for global windows user actions such mouse, keyboard, clipboard, & print events

<a href="https://ci.appveyor.com/project/justcoding121/windows-user-action-hook">Build Status</a>

Kindly report only issues/bugs here . For programming help or questions use StackOverflow with the tag EventHook or Windows-User-Action-Hook.

Supported Events

  • Keyboard events
  • Mouse events
  • clipboard events
  • application events
  • print events

Development enviroment

  • Visual Studio 2017

Usage

Install by nuget

Install-Package EventHook

Sample Code:

using (var eventHookFactory = new EventHookFactory())
{
    var keyboardWatcher = eventHookFactory.GetKeyboardWatcher();
    keyboardWatcher.Start();
    keyboardWatcher.OnKeyInput += (s, e) =>
    {
        Console.WriteLine(string.Format("Key {0} event of key {1}", e.KeyData.EventType, e.KeyData.Keyname));
    };

    var mouseWatcher = eventHookFactory.GetMouseWatcher();
    mouseWatcher.Start();
    mouseWatcher.OnMouseInput += (s, e) =>
    {
        Console.WriteLine(string.Format("Mouse event {0} at point {1},{2}", e.Message.ToString(), e.Point.x, e.Point.y));
    };

    var clipboardWatcher = eventHookFactory.GetClipboardWatcher();
    clipboardWatcher.Start();
    clipboardWatcher.OnClipboardModified += (s, e) =>
    {
        Console.WriteLine(string.Format("Clipboard updated with data '{0}' of format {1}", e.Data, e.DataFormat.ToString()));
    };


    var applicationWatcher = eventHookFactory.GetApplicationWatcher();
    applicationWatcher.Start();
    applicationWatcher.OnApplicationWindowChange += (s, e) =>
    {
        Console.WriteLine(string.Format("Application window of '{0}' with the title '{1}' was {2}", e.ApplicationData.AppName, e.ApplicationData.AppTitle, e.Event));
    };

    var printWatcher = eventHookFactory.GetPrintWatcher();
    printWatcher.Start();
    printWatcher.OnPrintEvent += (s, e) =>
    {
        Console.WriteLine(string.Format("Printer '{0}' currently printing {1} pages.", e.EventData.PrinterName, e.EventData.Pages));
    };

    //waiting here to keep this thread running           
    Console.Read();

    //stop watching
    keyboardWatcher.Stop();
    mouseWatcher.Stop();
    clipboardWatcher.Stop();
    applicationWatcher.Stop();
    printWatcher.Stop();
}

alt tag

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.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
2.1.1 311 10/15/2023
2.0.0 152 10/15/2023