Laz 0.695.3

dotnet add package Laz --version 0.695.3
                    
NuGet\Install-Package Laz -Version 0.695.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="Laz" Version="0.695.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Laz" Version="0.695.3" />
                    
Directory.Packages.props
<PackageReference Include="Laz" />
                    
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 Laz --version 0.695.3
                    
#r "nuget: Laz, 0.695.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 Laz@0.695.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=Laz&version=0.695.3
                    
Install as a Cake Addin
#tool nuget:?package=Laz&version=0.695.3
                    
Install as a Cake Tool

<div align="center">

<img src=".github/marketing-resources/logo.png" width="200px" alt="Laz Logo">

Laz

Automate mouse movements, keyboard input, and screen capture across Windows, Linux, and macOS.

Build Tests codecov NuGet NuGet Downloads .NET License: MIT

</div>

<br>

<p align="center"> <img src=".github/marketing-resources/demo.gif" width="600px" alt="Laz Demo"> </p>

Demo

<details> <summary>Screen recording: test Avalonia app on macOS.</summary>

<video src="https://github.com/user-attachments/assets/09fc686f-c8eb-44a1-bb32-a190f857f443"></video>

</details>

Install

dotnet add package Laz

Platform support

Laz works on Windows x64/ARM, Linux x64/ARM (glibc), and macOS x64/ARM. On Linux, Laz requires an X server for mouse and keyboard simulation. Supported RIDs: win-x64, win-arm64, linux-x64, linux-arm64, osx-x64, osx-arm64.

Quick start

using Laz;

var laz = new Laz();

laz.Mouse.MoveTo(100, 100);
laz.Mouse.Click();
laz.Keyboard.Type("Hello from Laz!");

Features

Mouse

All mouse methods return Mouse, so calls can be chained.

Jump to position

JumpTo(point) moves the cursor instantly. GetPosition() reads where it currently is.

laz.Mouse.JumpTo(new (500, 300));
Point pos = laz.Mouse.GetPosition();

Click

Click(button) presses and releases a button. DoubleClick(button) does it twice. Both default to the primary (left) button.

laz.Mouse.Click();
laz.Mouse.Click(MouseButton.Right);
laz.Mouse.DoubleClick();

Explicit button events

Press(button) holds a button down; Release(button) lets it go. Use these when DragAndDrop isn't flexible enough and you need full control over the timing.

laz.Mouse
   .Press()
   .JumpTo(new (800, 400))
   .Release();

Scroll

Scroll(notches) spins the wheel. Positive values scroll up, negative scroll down.

laz.Mouse.Scroll(3);
laz.Mouse.Scroll(-5);

Smooth movement

MoveTo(start, target) moves the cursor over time instead of jumping. You control the duration, path shape (Linear or Bezier), and easing function.

using Laz.Extensions.Mouse;

laz.Mouse.MoveTo(
    start: new (100, 100),
    target: new (900, 500),
    duration: TimeSpan.FromSeconds(1),
    moveFunction: MouseMoveFunction.Bezier,
    easingFunction: MoveEasingFunction.EaseInOut
);

Drag and drop

DragAndDrop(start, target) combines press, smooth move, and release. Pass dragPreamble: true to add a short downward nudge before the move; some applications need this to register the gesture correctly.

laz.Mouse.DragAndDrop(
    start: new (200, 300),
    target: new (700, 300)
);

Delay

Delay() pauses for the default delay between chained actions. The default is 50 ms; set the LAZ_DELAY_MS environment variable to change it.

laz.Mouse
   .Click()
   .Delay()
   .Click();

Keyboard

All keyboard methods return Keyboard, so calls can be chained.

Key down and up

Use KeyDown(key) to press a key and KeyUp(key) to release it. Use them together to send key combinations.

laz.Keyboard
   .KeyDown(Key.Control)
   .KeyDown(Key.Shift)
   .KeyDown(Key.Alt)
   .KeyUp(Key.Alt)
   .KeyUp(Key.Shift)
   .KeyUp(Key.Control);
laz.Keyboard
   .KeyDown(Key.Control)
   .Stroke(Key.C)
   .KeyUp(Key.Control);

Stroke a key

Stroke(key) presses and releases a single key with the default delay in between.

laz.Keyboard.Stroke(Key.Enter);
laz.Keyboard.Stroke(Key.Tab);
laz.Keyboard.Stroke(Key.ArrowDown);
laz.Keyboard.Stroke(Key.F5);

Type text

Type(text) turns a string into keystrokes. This method handles dead keys and characters that need modifier combinations. If a character can't be produced through key simulation, pass clipboardFallback: true to paste it using clipboard.

The clipboardFallback works only on Windows and macOS. On Windows, pass useCtrlInsert: true to use Ctrl/Shift+Insert instead of Ctrl+C/V.

using Laz.Extensions.Keyboard;

laz.Keyboard.Type("Hello, World!");
laz.Keyboard.Type("café");                        // Dead keys handled automatically.
laz.Keyboard.Type("€", clipboardFallback: true);  // Paste unsupported characters using clipboard. The rest is typed normally.

Delay

Delay() inserts a pause between actions. The default is 50 ms; set the LAZ_DELAY_MS environment variable to change it.

laz.Keyboard
   .Stroke(Key.F2)
   .Delay()
   .Type("new name")
   .Stroke(Key.Enter);

Screen

Capture a region

Capture(origin, width, height) takes a screenshot of the given rectangle. The result contains raw pixel data, width, and height. Data is in BGRA byte order, 4 bytes per pixel, rows from top to bottom.

var (data, width, height) = laz.Screen.Capture(new (0, 0), 1920, 1080);

Read a pixel color

GetColorAt(point) returns the color of a single pixel as (byte R, byte G, byte B, byte A). Useful for checking whether a UI element has appeared or changed state.

var (r, g, b, _) = laz.Screen.GetColorAt(new (100, 200));
bool isRed = r > 200 && g < 50 && b < 50;

Building

To learn how build the project and run the tests, check the BUILDING.md file or one of the GitHub Actions workflows.

Issues and contributing

Bug reports and pull requests are welcome. If you found a bug, include your OS, .NET version, and a minimal reproduction steps.

License

Laz is free and open-source software licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.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
0.695.3 41 9/30/2026
0.695.2 102 7/13/2026
0.695.1 290 7/2/2026
0.695.0 76 6/16/2026
0.0.595-rc1 73 6/16/2026
0.0.595-rc 123 3/1/2026
0.0.594-rc 63 3/1/2026