VirtualDesktop.WinForms
5.0.4
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package VirtualDesktop.WinForms --version 5.0.4
NuGet\Install-Package VirtualDesktop.WinForms -Version 5.0.4
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="VirtualDesktop.WinForms" Version="5.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VirtualDesktop.WinForms --version 5.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: VirtualDesktop.WinForms, 5.0.4"
#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.
// Install VirtualDesktop.WinForms as a Cake Addin #addin nuget:?package=VirtualDesktop.WinForms&version=5.0.4 // Install VirtualDesktop.WinForms as a Cake Tool #tool nuget:?package=VirtualDesktop.WinForms&version=5.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
VirtualDesktop
VirtualDesktop is C# wrapper for IVirtualDesktopManager on Windows 11 (and Windows 10).
Features
- Switch, add, and remove a virtual desktop.
- Move the window in the same process to any virtual desktop.
- Move the window of another process to any virtual desktop (Support in version 2.0 or later).
- Pin any window or application; will be display on all desktops.
- Notification for switching, deletion, renaming, etc.
- Change the wallpaper for each desktop.
Sample app
samples/VirtualDesktop.Showcase
Requirements
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
- .NET 6
- Windows 10 build 19041 (20H1) or later
Installation
Install NuGet package(s).
PM> Install-Package VirtualDesktop
- VirtualDesktop - Core classes for VirtualDesktop.
- VirtualDesktop.WPF - Provides extension methods for WPF Window class.
- VirtualDesktop.WinForms - Provides extension methods for Form class.
How to use
Preparation
Because of the dependency on C#/WinRT (repo), the target framework must be set to net6.0-windows10.0.19041.0
or later.
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
If it doesn't work, try creating an app.manifest
file and optimize to work on Windows 10.
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
The namespace to use is WindowsDesktop
.
using WindowsDesktop;
Get instance of VirtualDesktop class
// Get all virtual desktops
var desktops = VirtualDesktop.GetDesktops();
// Get Virtual Desktop for specific window
var desktop = VirtualDesktop.FromHwnd(hwnd);
// Get the left/right desktop
var left = desktop.GetLeft();
var right = desktop.GetRight();
Manage virtual desktops
// Create new
var desktop = VirtualDesktop.Create();
// Remove
desktop.Remove();
// Switch
desktop.GetLeft().Switch();
Subscribe virtual desktop events
// Notification of desktop switching
VirtualDesktop.CurrentChanged += (_, args) => Console.WriteLine($"Switched: {args.NewDesktop.Name}");
// Notification of desktop creating
VirtualDesktop.Created += (_, desktop) => desktop.Switch();
for WPF window
// Need to install 'VirtualDesktop.WPF' package
// Check whether a window is on the current desktop.
var isCurrent = window.IsCurrentVirtualDesktop();
// Get Virtual Desktop for WPF window
var desktop = window.GetCurrentDesktop();
// Move window to specific Virtual Desktop
window.MoveToDesktop(desktop);
// Pin window
window.Pin()
See also:
License
This library is under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows10.0.19041 is compatible. net7.0-windows was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0-windows10.0.19041
- VirtualDesktop (>= 5.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.