Poss.Win.Automation 1.0.5

dotnet add package Poss.Win.Automation --version 1.0.5
                    
NuGet\Install-Package Poss.Win.Automation -Version 1.0.5
                    
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="Poss.Win.Automation" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Poss.Win.Automation" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Poss.Win.Automation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Poss.Win.Automation --version 1.0.5
                    
#r "nuget: Poss.Win.Automation, 1.0.5"
                    
#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.
#:package Poss.Win.Automation@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Poss.Win.Automation&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Poss.Win.Automation&version=1.0.5
                    
Install as a Cake Tool

Poss.Win.Automation

<em>Windows automation library</em> for keyboard and mouse input simulation, global hotkey registration, and window management. Targets .NET Standard 2.0.

Features

  • InputSimulator — simulate keyboard and mouse input (key presses, clicks, cursor movement, Unicode text)
  • Key parsing prechecks — validate key/chord strings with TryParse / TryParseKey before sending input or registering hotkeys
  • GlobalHotKeyManager — register system-wide hotkeys with keyboard and mouse support
  • Window utilities — activate windows, query titles, positions, process names

Installation

dotnet add package Poss.Win.Automation

Quick Start

Input simulation

using Poss.Win.Automation.Input;

var sim = new InputSimulator();
sim.SendText("Hello, World!");
sim.Click(100, 200, "LButton");
sim.Send("Ctrl");

Global hotkeys

using Poss.Win.Automation.GlobalHotKeys;

var manager = new GlobalHotKeyManager(new GlobalHotKeyManagerOptions { RunMessageLoop = true });
manager.Start();

manager.Register("save", async () => { /* save action */ }, "Ctrl+S");
manager.Register("custom", async () => { /* action */ }, "Shift+LButton Up");

// manager.Stop(); manager.Dispose();

Process filtering (input only when window is active)

using Poss.Win.Automation.Input;

// Restrict input to Notepad — SendText/Click/etc. are no-ops when another app is focused
var sim = new InputSimulator("notepad");
sim.SendText("Typed into Notepad only");
sim.Click(100, 100);

Console apps: use RunMessageLoop

using Poss.Win.Automation.GlobalHotKeys;

// Hooks require a Windows message loop. In WinForms/WPF it exists; in console apps you must enable it:
var manager = new GlobalHotKeyManager(new GlobalHotKeyManagerOptions { RunMessageLoop = true });
manager.Start();
manager.Register("quit", async () => { Environment.Exit(0); }, "Ctrl+Q");
// Keep running

Key actions: Down, Up, Press

sim.Send("Ctrl down");   // Hold Ctrl
sim.Send("A");          // Press A (with Ctrl held)
sim.Send("Ctrl up");    // Release Ctrl

// Trigger-on-release hotkey
manager.Register("onRelease", async () => { /* fires when key is released */ }, "F5 Up");

Validate key strings (precheck)

Use TryParse / TryParseKey to validate key names before calling Send, GetKeyState, or registering hotkeys — without throwing.

using Poss.Win.Automation.Common.Keys.Enums;
using Poss.Win.Automation.Common.Structs;
using Poss.Win.Automation.Input;
using Poss.Win.Automation.GlobalHotKeys.Structs;

// Single key name only (no action): "1", "D1", "Ctrl", "LButton", ";"
if (KeyStroke.TryParseKey("1", out VirtualKey key))
    Console.WriteLine(key);  // D1

// Raw VK code for a key name
if (KeyStroke.TryGetVirtualKeyCode("F5", out ushort vkCode)) { /* ... */ }

// Key + optional action: "A", "D1 Down", "LButton click"
if (KeyStroke.TryParse("Ctrl Down", out KeyStroke stroke))
    sim.Send(stroke);

// Same as KeyStroke.TryParse, with InputSimulator's parse cache
if (InputSimulator.TryParse("1 Down", out KeyStroke cached))
    sim.Send(cached);

// Chord (parts separated by '+'): "Ctrl + 1", "Shift + LButton Up"
if (HotkeyCombination.TryParse("Ctrl + S", out _))
    manager.Register("save", async () => { }, "Ctrl + S");

Accepted key formats:

  • Enum namesD1, Ctrl, F5, LButton, NumPad3 (case-insensitive)
  • Row digits"0""9" map to D0D9 (not mouse VK codes)
  • Single lettersA / a
  • Symbol literals; = , - . / ` [ \ ] '

Space in a stroke string separates key from action (Down, Up, Press, Click), not multiple keys. Use + for chords (HotkeyCombination). Multi-digit numeric strings (e.g. "17") are rejected.

Mouse and window utilities

sim.MouseSetPos(500, 300);
sim.MouseDeltaMove(600, 400, speed: 2.0);  // Smooth movement with easing
sim.MouseWheel(120);   // Scroll up (negative = down)

sim.WinActivate("notepad");  // Activate first window matching process or title
var pos = sim.MouseGetPos();
var title = sim.GetWindowTitle();

Limitations

  • Windows only — Uses Win32 APIs (SendInput, SetWindowsHookEx, etc.). Does not run on Linux or macOS.
  • UIPI — Input sent via SendInput may be blocked when targeting elevated processes from a non-elevated app (and vice versa).
  • Message loop — Global hotkeys need a Windows message loop. In console apps, set RunMessageLoop = true.
  • Process filter — InputSimulator with a process filter only simulates input when the matching window is foreground; calls are no-ops otherwise.

Keywords

windows, automation, input, keyboard, mouse, hotkey, global hotkey, keyboard hook, mouse hook, input simulation, SendInput, Win32, .NET Standard, C#

Documentation

Requirements

  • .NET Standard 2.0
  • Windows (uses Win32 APIs: SendInput, SetWindowsHookEx, etc.)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.5 122 6/14/2026
1.0.4 119 6/14/2026
1.0.3 140 2/15/2026
1.0.2 124 2/15/2026
1.0.1 136 2/4/2026
1.0.0 133 2/2/2026

Fix KeyStroke key parsing: single-digit keys (0-9), parse order, and reject multi-digit numeric strings.