Skip to content

Wrapper for API to Virtual Desktop on Windows 10.

License

Notifications You must be signed in to change notification settings

strizi254/VirtualDesktop

 
 

Repository files navigation

VirtualDesktop

VirtualDesktop is C# wrapper for IVirtualDesktopManager on 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).

Installation

Install NuGet package(s).

PM> Install-Package VirtualDesktop

How to use

Preparation:

<!-- Please create application manifest file and run without debugging. -->
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
	    <!-- Windows 10 -->
	    <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
    </application>
</compatibility>
using WindowsDesktop;

Get instance of VirtualDesktop:

// 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.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);

See also:

License

This library is under the MIT License.

About

Wrapper for API to Virtual Desktop on Windows 10.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.9%
  • Batchfile 0.1%