Unfucked.Windows 0.0.1-beta.6

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

🧰 Unfucked.Windows

NuGet GitHub Actions Testspace Coveralls

Fix egregiously missing or broken functionality in .NET libraries that integrate with Windows APIs.

Unfuck your house

Installation

dotnet add package 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
      string args = Processes.CommandLineToString(["arg1", "'argument' \"2\""]);
      

Console

  • Detach a console application from its console window if you want to prevent it from receiving Ctrl+C, 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.GetProcessExecutableBasename();
    
  • Get parent process of a process
    Process? parent = Process.GetCurrentProcess().GetParentProcess();
    
  • Get descendant processes recursively of a process
    IEnumerable<Process> decendants = Process.GetCurrentProcess().GetDescendantProcesses();
    
  • Detect if a process is suspended
    bool isSuspended = Process.GetProcessById(pid).IsProcessSuspended();
    

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();
    

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 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. 
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 (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.6 174 11/6/2025
0.0.1-beta.5 208 7/9/2025
0.0.1-beta.4 145 7/3/2025
0.0.1-beta.3 167 6/24/2025
0.0.1-beta.2 142 6/6/2025
0.0.1-beta.1 135 4/12/2025
0.0.0-beta5 171 3/11/2025
0.0.0-beta4 204 3/6/2025
0.0.0-beta3 104 9/30/2024
0.0.0-beta2 83 9/8/2024