WIWrapper 1.0.3

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package WIWrapper --version 1.0.3
                    
NuGet\Install-Package WIWrapper -Version 1.0.3
                    
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="WIWrapper" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WIWrapper" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="WIWrapper" />
                    
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 WIWrapper --version 1.0.3
                    
#r "nuget: WIWrapper, 1.0.3"
                    
#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 WIWrapper@1.0.3
                    
#: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=WIWrapper&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=WIWrapper&version=1.0.3
                    
Install as a Cake Tool

WIWrapper: A Fluent Windows Input Simulator

NuGet Version License: MIT Platform

WIWrapper (Windows Input Wrapper) is a simple, modern and intuitive .NET library for simulating keyboard and mouse input in Windows. It provides a convenient fluent wrapper over the low-level SendInput API, turning complex operations into elegant and readable call chains.

✨ Features

  • Fluent API: Create sequences of actions using intuitive chains of methods (.KeyDown().MouseMove().MouseClick()).
  • Full keyboard simulation: Supports keystrokes using virtual codes (KeyCodes), as well as entering Unicode characters for any language.
  • Precise mouse control: Move the cursor in absolute or relative coordinates, simulate clicks of the left, middle, right and side (xButton) buttons.
  • Batch sending: All input commands are accumulated and sent by a single system call SendInputs(), which ensures high performance and reliability.
  • Ease of use: No complicated structures or P/Invoke in your code. Just create an instance of InputWrapper and start acting.
  • Automation: Ideal for creating bots, UI testing automation tools, and any applications that require programmatic input management.

Installation

The library is available as a NuGet package. You can install it using .NET CLI or Package Manager Console.

.NET CLI

dotnet add package WIWrapper

Package Manager Console

Install-Package WIWrapper

🎯 Quick Start

The main idea of the library is to build a chain of commands and execute them using the SendInputs() method.

Example 1: Typing and pressing Enter

using WIWrapper;
using WIWrapper.BackEnd.NativeInputs.Keyboard;

// Create an instance, build a chain of commands and send them
new InputWrapper()
  .TypeString("Hello, automated world!")
  .KeyType(KeyCodes.Enter)
  .SendInputs();

Example 2: Drawing a square with the mouse

This example demonstrates holding down a button, moving the mouse, and releasing it.

using WIWrapper;
using WIWrapper.BackEnd.NativeInputs.Mouse;

// Setting the cursor to the starting position
var wrapper = new InputWrapper();
wrapper.MouseSet(500, 500).SendInputs();

// Draw a 100x100px square

wrapper
  .MouseButton(MouseButton.Left, down: true) // Hold down the left button
  .MouseMove(100, 0) // Move to the right
  .MouseMove(0, 100) // Moving down
  .MouseMove(-100, 0) // Move to the left
  .MouseMove(0, -100) // Upward movement
  .MouseButton(MouseButton.Left, down: false) // Release the left button
  .SendInputs();

Example 3: Keyboard shortcuts (Open Notepad and enter text)

using WIWrapper;
using WIWrapper.BackEnd.NativeInputs.Keyboard;

// 1. Press Win+R to open "Run"
var wrapper = new InputWrapper()

wrapper.KeyDown(KeyCodes.LWin)
  .KeyType(KeyCodes.R)
  .KeyUp(KeyCodes.LWin)
  .SendInputs();

// Giving the window time to appear
Thread.Sleep(500);

// 2. Enter "notepad" and press Enter

wrapper.TypeString("notepad")
  .KeyType(KeyCodes.Enter)
  .SendInputs();

// Giving the notebook time to open
Thread.Sleep(500);
// 3. Print text in notepad
wrapper.TypeString("WIWrapper is awesome!")
  .SendInputs();

📚 API Overview

Method Description
KeyDown(key) Simulates pressing (down) a key by its KeyCode.
KeyUp(key) Simulates the release (up) of the key.
KeyType(key) Simulates full pressing (down, then up).
TypeString(str) Prints a string using Unicode characters.
TypeChar(ch) Prints a single Unicode character.
MouseSet(x, y) Sets the cursor to the absolute coordinates of the screen.
MouseMove(dx, dy) Moves the cursor to the specified offset (relative to).
MouseButton(btn, down) Presses or releases the left, right, or middle mouse button.
MouseClick(btn) Simulates a full click (down, then up).
MouseXButton(num, down) Presses or releases the side mouse buttons (1 or 2).
MouseXClick(num) Simulates a full click of the side button.
SendInputs() Executes all commands in the queue.

Assistance

We welcome any input! If you find a bug, have suggestions for improvement, or want to add a new feature.:

  1. Open Issue to discuss your idea.
  2. Make a fork of the repository.
  3. Create a new branch for your changes.
  4. Send Pull Request.

📜 License

This project is distributed under the MIT license. For more information, see the LICENSE file.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.
  • net9.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

Added vertical nad horizontal scroll into wrapper