Unfucked.Windows
0.0.1-beta.12
dotnet add package Unfucked.Windows --version 0.0.1-beta.12
NuGet\Install-Package Unfucked.Windows -Version 0.0.1-beta.12
<PackageReference Include="Unfucked.Windows" Version="0.0.1-beta.12" />
<PackageVersion Include="Unfucked.Windows" Version="0.0.1-beta.12" />
<PackageReference Include="Unfucked.Windows" />
paket add Unfucked.Windows --version 0.0.1-beta.12
#r "nuget: Unfucked.Windows, 0.0.1-beta.12"
#:package Unfucked.Windows@0.0.1-beta.12
#addin nuget:?package=Unfucked.Windows&version=0.0.1-beta.12&prerelease
#tool nuget:?package=Unfucked.Windows&version=0.0.1-beta.12&prerelease
🧰 Unfucked.Windows
Fix egregiously missing or broken functionality in .NET libraries that integrate with Windows APIs.
Installation
dotnet package add Unfucked.Windows
using Unfucked;
using Unfucked.Windows;
Usage
Arguments
- Command line argument marshalling with correct escaping and quoting
- String to array
IEnumerable<string> argv = WindowsProcesses.CommandLineToEnumerable("arg1 arg2"); - Array to string (in the
Unfuckedlibrary,Unfucked.Windowsis not required)string args = Process.CommandLineToString(["arg1", "'argument' \"2\""]);
- String to array
- Get command line for processes not started by the current process, includes program filename
- One big string
string commandLine = process.CommandLine; // "C:\path\to\myprogram.exe --arg1 --arg2" - Split into tokens
IEnumerable<string> commandLine = process.CommandLineSplit; // ["C:\path\to\myprogram.exe", "--arg1", "--arg2"]
- One big string
Console
- Detach a console application from its console window if you want to prevent it from receiving <kbd>Ctrl</kbd>+<kbd>C</kbd>, because it's a child process of your console application, you're handling that signal in your parent process using
Console.CancelKeyPress, and you don't want the console sidestepping your parent and killing your child.using Process child = Process.Start("child.exe", "args")!; child.DetachFromConsole();
Internationalization
- Get locale of the operating system, rather than the user
CultureInfo machineCulture = Cultures.CurrentMachineCulture;
Processes
- Easier to get program's basename without memory leaks
string? basename = SystemWindow.ForegroundWindow.ProcessExecutableBasename; - Get parent process of a process
using Process? parent = Process.GetCurrentProcess().Parent; parent = Process.GetParentProcess(childPid); - Get descendant processes recursively of a process
IEnumerable<Process> decendants = Process.GetCurrentProcess().Descendants; - Suspend or resume a process
using Process process = Process.GetProcessById(pid) bool isSuspended = process.Suspended; process.Suspended = true; process.Suspended = false; - Detect if a process is elevated (running as administrator)
bool isElevated = Process.GetCurrentProcess().IsProcessElevated(); - Get process command line, even for processes not started by this process
Security
Determine if the user who ran a process is a member of the Administrators group, and if it's running elevated.
WindowsIdentity.GetCurrent().AdministratorElevation<dl> <dt><code>ElevatedAdmin</code></dt> <dd>User is an administrator, and the process is running elevated</dd> <dt><code>UnelevatedAdmin</code></dt> <dd>User is an administrator, but the process is not running elevated</dd> <dt><code>NotAdmin</code></dt> <dd>User is not an administrator, and cannot run any processes elevated</dd> </dl>
Standby and screensaver
- Reliably detect when computer is entering and exiting standby
using IStandbyListener standbyListener = new EventLogStandbyListener(); standbyListener.StandingBy += (_,_) => Console.WriteLine("The computer is entering sleep mode"); standbyListener.Resumed += (_,_) => Console.WriteLine("The computer woke up from sleep mode"); - Kill the running screensaver
new ScreensaverKiller().KillScreensaver();
Storage
- Get a file's size on disk. This can be larger than the file's intrinsic size because of cluster size rounding up, or it can be smaller due to NTFS compression or sparse (e.g. partially downloaded) files.
ulong sizeOnDiskBytes = new FileInfo("filename.txt").LengthOnDisk;
UI Automation
- Convert between Win32 window handles, UI Automation elements, and mwinapi window instances
AutomationElement? automationElement = SystemWindow.ForegroundWindow.ToAutomationElement(); SystemWindow foreground = foregroundUiaElementd.ToSystemWindow(); IntPtr? foregroundHwnd = automationElement.ToHwnd(); - Easily get all children of a UI Automation element
IEnumerable<AutomationElement> children = automationElement.Children(); - Create a UI Automation property AND or OR condition that doesn't crash if there is only one sub-condition
IEnumerable<string> allowedNames = ["A"]; automationElement.FindFirst(TreeScope.Children, UIAutomationExtensions.SingletonSafePropertyCondition(AutomationElement.NameProperty, false, allowedNames)); - Find a child or descendant UI Automation element and wait if it doesn't immediately exist, instead of returning null, to prevent UI rendering race conditions
AutomationElement? a = automationElement.WaitForFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "A"), TimeSpan.FromSeconds(30), cancellationToken);
All Unfucked libraries
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. net9.0-windows was computed. net10.0-windows was computed. |
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- mwinapi (>= 0.3.0.6)
- ThrottleDebounce (>= 3.0.0-beta6)
- Unfucked (>= 0.0.1-beta.49)
-
net6.0-windows7.0
- mwinapi (>= 0.3.0.6)
- ThrottleDebounce (>= 3.0.0-beta6)
- Unfucked (>= 0.0.1-beta.49)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Unfucked.Windows:
| Repository | Stars |
|---|---|
|
Aldaviva/AuthenticatorChooser
🗝️ Background program that skips the phone pairing option and chooses the USB security key in Windows FIDO/WebAuthn prompts.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1-beta.12 | 59 | 7/5/2026 |
| 0.0.1-beta.11 | 130 | 4/16/2026 |
| 0.0.1-beta.9 | 90 | 4/6/2026 |
| 0.0.1-beta.8 | 80 | 4/3/2026 |
| 0.0.1-beta.6 | 286 | 11/6/2025 |
| 0.0.1-beta.5 | 245 | 7/9/2025 |
| 0.0.1-beta.4 | 178 | 7/3/2025 |
| 0.0.1-beta.3 | 203 | 6/24/2025 |
| 0.0.1-beta.2 | 184 | 6/6/2025 |
| 0.0.1-beta.1 | 175 | 4/12/2025 |
| 0.0.0-beta5 | 212 | 3/11/2025 |
| 0.0.0-beta4 | 236 | 3/6/2025 |
| 0.0.0-beta3 | 136 | 9/30/2024 |
| 0.0.0-beta2 | 126 | 9/8/2024 |
