A comprehensive .NET library providing Windows-specific functionality for .NET Framework and .NET Core applications.
Dapplo.Windows is a collection of packages that provide P/Invoke wrappers and higher-level abstractions for Windows API functionality. Originally developed for Greenshot, this library makes it easy to interact with Windows features from managed code.
| Package | NuGet | Description |
|---|---|---|
| Dapplo.Windows.User32 | User32.dll wrappers | |
| Dapplo.Windows.Gdi32 | GDI32.dll wrappers | |
| Dapplo.Windows.Kernel32 | Kernel32.dll wrappers |
- Query window properties (title, bounds, class name, process, etc.)
- Enumerate windows with filtering
- Monitor window events (creation, destruction, title changes, etc.)
- Manipulate windows (show, hide, minimize, maximize, move, resize)
- Low-level keyboard hooks using Reactive Extensions
- Low-level mouse hooks using Reactive Extensions
- Generate keyboard input (type text, key combinations)
- Generate mouse input (move, click, scroll)
- Key combination and sequence handlers
- Monitor clipboard changes with Reactive Extensions
- Access clipboard content in various formats (text, files, images, streams)
- Set clipboard content
- Delayed rendering support
- Control Windows Cloud Clipboard and Clipboard History behavior
- DPI-aware forms for Windows Forms
- DPI handlers for custom scaling logic
- DPI calculations and conversions
- Bitmap scaling with quality preservation
- Support for both Windows Forms and WPF
- Comprehensive User32 API wrappers
- GDI32 graphics API wrappers
- Kernel32 system API wrappers
- Proper SafeHandle usage for resource management
- Well-defined structs and enums
- Citrix session detection and querying
- Desktop Window Manager (DWM) integration
- Enhanced WebBrowser control with configurable IE version
- Software installation enumeration
- Icon extraction
- And much more...
Install-Package Dapplo.Windows
Install-Package Dapplo.Windows.Clipboard
Install-Package Dapplo.Windows.Dpi
Install-Package Dapplo.Windows.Inputusing Dapplo.Windows.Desktop;
var subscription = WinEventHook.Create(WinEvents.EVENT_OBJECT_NAMECHANGE)
.Subscribe(winEvent =>
{
var window = InteropWindow.FromHandle(winEvent.Handle);
Console.WriteLine($"Window title changed: {window.GetCaption()}");
});using Dapplo.Windows.Clipboard;
using System.Reactive.Linq;
var subscription = ClipboardNative.OnUpdate
.Where(info => info.Formats.Contains("Text"))
.Subscribe(info =>
{
using var clipboard = ClipboardNative.Access();
var text = clipboard.GetAsString();
Console.WriteLine($"Clipboard: {text}");
});using Dapplo.Windows.Clipboard;
// Prevent sensitive data from being saved to clipboard history or cloud
using (var clipboard = ClipboardNative.Access())
{
clipboard.SetAsUnicodeString("MyPassword123!");
clipboard.SetCloudClipboardOptions(
canIncludeInHistory: false,
canUploadToCloud: false
);
}using Dapplo.Windows.Dpi.Forms;
public class MyForm : DpiAwareForm
{
public MyForm()
{
InitializeComponent();
// Form automatically scales with DPI changes
}
}using Dapplo.Windows.Input.Keyboard;
using System.Reactive.Linq;
var keyboardHook = KeyboardHook.Create();
var subscription = keyboardHook.KeyboardEvents
.Where(e => e.Key == VirtualKeyCode.A && e.IsDown)
.Subscribe(e => Console.WriteLine("'A' pressed"));- Full Documentation - Complete guides and API reference
- Getting Started - Quick start guide with examples
- API Reference - Detailed API documentation
The repository includes example projects:
- Dapplo.Windows.Example.ConsoleDemo - Console application examples
- Dapplo.Windows.Example.FormsExample - Windows Forms examples
- Dapplo.Windows.Example.WpfExample - WPF application examples
- .NET Framework 4.6.2 or higher
- .NET Core 3.1 or higher / .NET 5+ (for most packages)
- Windows operating system
Contributions are welcome! Please feel free to submit issues and pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
Originally developed for Greenshot, this library has been extracted into a standalone project for easier maintenance and reuse.