Skip to content

Commit

Permalink
Version 1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
MScholtes authored Sep 17, 2023
1 parent 2bc5e25 commit 546b673
Show file tree
Hide file tree
Showing 11 changed files with 2,805 additions and 44 deletions.
4 changes: 4 additions & 0 deletions Changes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changes:

Version 1.16, 2023-09-17
- version for Windows 11 Insider Canary (build 25314 and up) called VirtualDesktop11InsiderCanary.cs
- (re)introduced parameter /RemoveAll for all versions

Version 1.15, 2023-09-02
- bug fix for Win 11 22H2 Build 22621.2215

Expand Down
1 change: 1 addition & 0 deletions Compile.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ setlocal

C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe "%~dp0VirtualDesktop11.cs" /win32icon:"%~dp0MScholtes.ico"
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe "%~dp0VirtualDesktop11-23H2.cs" /win32icon:"%~dp0MScholtes.ico"
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe "%~dp0VirtualDesktop11InsiderCanary.cs" /win32icon:"%~dp0MScholtes.ico"
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe "%~dp0VirtualDesktop11-21H2.cs" /win32icon:"%~dp0MScholtes.ico"
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe "%~dp0VirtualDesktop.cs" /win32icon:"%~dp0MScholtes.ico"
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe "%~dp0VirtualDesktopServer2022.cs" /win32icon:"%~dp0MScholtes.ico"
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ C# command line tool to manage virtual desktops in Windows 10 and Windows 11

**Pre-compiled binaries in Releases now**

**Version 1.15, 2023-09-02**
- bug fix for Win 11 22H2 Build 22621.2215, 2023/09/02
**Version 1.16, 2023-09-17**
- version for Windows 11 Insider Canary (build 25314 and up) called VirtualDesktop11InsiderCanary.cs
- (re)introduced parameter /RemoveAll for all versions

(look for a powershell version here: https://github.com/MScholtes/PSVirtualDesktop or here: https://www.powershellgallery.com/packages/VirtualDesktop)

**With Windows 11 22H2 Release 2215 Microsoft did change the API (COM GUIDs) for accessing the functions for virtual desktops again. I provide six versions of virtualdesktop.cs now: virtualdesktop11.cs is for Windows 11 22H2 up to release 2134, virtualdesktop11-23h2.cs for Windows 11 22H2 release 2215 and newer (including Insider) versions, virtualdesktop11-21h2.cs for Windows 11 21H2, virtualdesktopserver2022.cs is for Windows Server 2022, virtualdesktop.cs is for Windows 10 1809 to 22H2, virtualdesktopserver2016.cs is for Windows Server 2016. Using Compile.bat all executables will be generated.**
**With Windows 11 22H2 Release 2215 Microsoft did change the API (COM GUIDs) for accessing the functions for virtual desktops again. I provide seven versions of virtualdesktop.cs now: virtualdesktop11.cs is for Windows 11 22H2 up to release 2134, virtualdesktop11-23h2.cs for Windows 11 22H2 release 2215 and newer (including Insider except Canary) versions, virtualdesktop11-21h2.cs for Windows 11 21H2, virtualdesktop11insidercanary.cs for Windows 11 Insider Canary, virtualdesktopserver2022.cs is for Windows Server 2022, virtualdesktop.cs is for Windows 10 1809 to 22H2, virtualdesktopserver2016.cs is for Windows Server 2016. Using Compile.bat all executables will be generated.**

**I will make a cleanup of versions with the next release!**

## Generate:
Compile with Compile.bat (no visual studio needed, but obviously Windows 10 or 11)
Expand Down Expand Up @@ -53,7 +56,7 @@ Virtual desktop numbers start with 0.

**/Remove[:<n|s>]**    remove desktop number <n>, desktop with text <s> in name or desktop with number in pipeline (short: /r).

**/RemoveAll** remove all desktops but visible (short: /ra)(only VirtualDesktop11.exe).
**/RemoveAll** remove all desktops but visible (short: /ra).

**/SwapDesktop:<n|s>** swap desktop in pipeline with desktop number <n>, desktop with text <s> in name or desktop with number in pipeline (short: /sd).

Expand Down
28 changes: 14 additions & 14 deletions ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ VirtualDesktop

C# command line tool to manage virtual desktops in Windows 10 and Windows 11

Version 1.15, 2023-09-02
- bug fix for Win 11 22H2 Build 22621.2215
Version 1.16, 2023-09-17
- version for Windows 11 Insider Canary (build 25314 and up) called VirtualDesktop11InsiderCanary.cs
- (re)introduced parameter /RemoveAll for all versions

(look for a powershell version here:
https://gallery.technet.microsoft.com/Powershell-commands-to-d0e79cc5
or here:
https://www.powershellgallery.com/packages/VirtualDesktop)


With Windows 11 22H2 Microsoft did change the API (COM GUIDs) for accessing the
functions for virtual desktops again. I provide six versions of
virtualdesktop.cs now: virtualdesktop11.cs is for Windows 11, virtualdesktop11-
21h2.cs for Windows 11 21H2, virtualdesktopserver2022.cs is for Windows Server
2022, virtualdesktop.cs is for Windows 10 1809 to 21H2,
virtualdesktopserver2016.cs is for Windows Server 2016. Using Compile.bat all
executables will be generated.

See:
https://github.com/Grabacr07/VirtualDesktop/issues/29
https://github.com/mzomparelli/zVirtualDesktop/wiki
With Windows 11 22H2 Release 2215 Microsoft did change the API (COM GUIDs) for
accessing the functions for virtual desktops again. I provide seven versions of
virtualdesktop.cs now: virtualdesktop11.cs is for Windows 11 22H2 up to release
2134, virtualdesktop11-23h2.cs for Windows 11 22H2 release 2215 and newer
(including Insider except Canary) versions, virtualdesktop11-21h2.cs for Windows
11 21H2, virtualdesktop11insidercanary.cs for Windows 11 Insider Canary,
virtualdesktopserver2022.cs is for Windows Server 2022, virtualdesktop.cs is for
Windows 10 1809 to 22H2, virtualdesktopserver2016.cs is for Windows Server 2016.
Using Compile.bat all executables will be generated.

I will make a cleanup of versions with the next release!

Generate:
Compile with Compile.bat (no visual studio needed, but obviously Windows 10 or 11)
Expand Down Expand Up @@ -56,7 +56,7 @@ Parameters (leading / can be omitted or - can be used instead):
/Wrap /NoWrap /Left or /Right switch over or generate an error when the edge is reached (default)(short /w and /nw).
/New create new desktop (short: /n). Number is stored in pipeline.
/Remove[:<n|s>] remove desktop number <n>, desktop with text <s> in name or desktop with number in pipeline (short: /r).
/RemoveAll remove all desktops but visible (short: /ra)(only VirtualDesktop11.exe).
/RemoveAll remove all desktops but visible (short: /ra).
/SwapDesktop:<n|s> swap desktop in pipeline with desktop number <n>, desktop with text <s> in name or desktop with number in pipeline (short: /sd).
/InsertDesktop:<n|s> insert desktop number <n> or desktop with text <s> in name before desktop in pipeline or vice versa (short: /id)(not VirtualDesktop11.exe).
/MoveDesktop:<n|s> move desktop in pipeline to desktop number <n> or desktop with text <s> in name (short: /md)(only VirtualDesktop11.exe).
Expand Down
39 changes: 35 additions & 4 deletions VirtualDesktop.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Author: Markus Scholtes, 2023
// Version 1.14, 2023-08-29
// Version 1.16, 2023-09-17
// Version for Windows 10 1809 to 22H2
// Compile with:
// C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe VirtualDesktop.cs
Expand All @@ -20,8 +20,8 @@
[assembly:AssemblyCopyright("© Markus Scholtes 2023")]
[assembly:AssemblyTrademark("")]
[assembly:AssemblyCulture("")]
[assembly:AssemblyVersion("1.14.0.0")]
[assembly:AssemblyFileVersion("1.14.0.0")]
[assembly:AssemblyVersion("1.16.0.0")]
[assembly:AssemblyFileVersion("1.16.0.0")]

// Based on http://stackoverflow.com/a/32417530, Windows 10 SDK, github project Grabacr07/VirtualDesktop and own research

Expand Down Expand Up @@ -503,6 +503,23 @@ public void Remove(Desktop fallback = null)
DesktopManager.VirtualDesktopManagerInternal.RemoveDesktop(ivd, fallbackdesktop);
}

public static void RemoveAll()
{ // remove all desktops but visible
int desktopcount = DesktopManager.VirtualDesktopManagerInternal.GetCount();
int desktopcurrent = DesktopManager.GetDesktopIndex(DesktopManager.VirtualDesktopManagerInternal.GetCurrentDesktop());

if (desktopcurrent < desktopcount-1)
{ // remove all desktops "right" from current
for (int i = desktopcount-1; i > desktopcurrent; i--)
DesktopManager.VirtualDesktopManagerInternal.RemoveDesktop(DesktopManager.GetDesktop(i), DesktopManager.VirtualDesktopManagerInternal.GetCurrentDesktop());
}
if (desktopcurrent > 0)
{ // remove all desktops "left" from current
for (int i = 0; i < desktopcurrent; i++)
DesktopManager.VirtualDesktopManagerInternal.RemoveDesktop(DesktopManager.GetDesktop(0), DesktopManager.VirtualDesktopManagerInternal.GetCurrentDesktop());
}
}

public void SetName(string Name)
{ // set name for desktop, empty string removes name
if (DesktopManager.VirtualDesktopManagerInternal2 != null)
Expand Down Expand Up @@ -946,6 +963,19 @@ static int Main(string[] args)
}
break;

case "REMOVEALL": // remove all virtual desktops but visible
case "RA":
Console.WriteLine("Removing all virtual desktops but visible");
try
{ // remove all virtual desktops but visible
VirtualDesktop.Desktop.RemoveAll();
}
catch
{ // error while removing
rc = -1;
}
break;

case "MOVEACTIVEWINDOW": // move active window to desktop in rc
case "MAW":
if (verbose) Console.WriteLine("Moving active window to virtual desktop number " + rc.ToString());
Expand Down Expand Up @@ -2542,7 +2572,7 @@ private static void InsertDesktop(int InsertIndex1, int InsertIndex2)

static void HelpScreen()
{
Console.WriteLine("VirtualDesktop.exe\t\t\t\tMarkus Scholtes, 2023, v1.14\n");
Console.WriteLine("VirtualDesktop.exe\t\t\t\tMarkus Scholtes, 2023, v1.16\n");

Console.WriteLine("Command line tool to manage the virtual desktops of Windows 10.");
Console.WriteLine("Parameters can be given as a sequence of commands. The result - most of the");
Expand Down Expand Up @@ -2573,6 +2603,7 @@ static void HelpScreen()
Console.WriteLine("/New create new desktop (short: /n). Number is stored in pipeline.");
Console.WriteLine("/Remove[:<n|s>] remove desktop number <n>, desktop with text <s> in name or");
Console.WriteLine(" desktop with number in pipeline (short: /r).");
Console.WriteLine("/RemoveAll remove all desktops but visible (short: /ra).");
Console.WriteLine("/SwapDesktop:<n|s> swap desktop in pipeline with desktop number <n> or desktop");
Console.WriteLine(" with text <s> in name (short: /sd).");
Console.WriteLine("/InsertDesktop:<n|s> insert desktop number <n> or desktop with text <s> in");
Expand Down
8 changes: 4 additions & 4 deletions VirtualDesktop11-21H2.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Author: Markus Scholtes, 2023
// Version 1.14, 2023-08-29
// Version 1.16, 2023-09-17
// Version for Windows 11 21H2
// Compile with:
// C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe VirtualDesktop11.cs
Expand All @@ -20,8 +20,8 @@
[assembly:AssemblyCopyright("© Markus Scholtes 2023")]
[assembly:AssemblyTrademark("")]
[assembly:AssemblyCulture("")]
[assembly:AssemblyVersion("1.14.0.0")]
[assembly:AssemblyFileVersion("1.14.0.0")]
[assembly:AssemblyVersion("1.16.0.0")]
[assembly:AssemblyFileVersion("1.16.0.0")]

// Based on http://stackoverflow.com/a/32417530, Windows 10 SDK, github project Grabacr07/VirtualDesktop and own research

Expand Down Expand Up @@ -2526,7 +2526,7 @@ private static void SwapDesktops(int SwapIndex1, int SwapIndex2)

static void HelpScreen()
{
Console.WriteLine("VirtualDesktop.exe\t\t\t\tMarkus Scholtes, 2023, v1.14\n");
Console.WriteLine("VirtualDesktop.exe\t\t\t\tMarkus Scholtes, 2023, v1.16\n");

Console.WriteLine("Command line tool to manage the virtual desktops of Windows 11.");
Console.WriteLine("Parameters can be given as a sequence of commands. The result - most of the");
Expand Down
23 changes: 17 additions & 6 deletions VirtualDesktop11-23H2.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Author: Markus Scholtes, 2023
// Version 1.15, 2023-08-29
// Version 1.16, 2023-09-17
// Version for Windows 11 22H2.2215 and up
// Compile with:
// C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe VirtualDesktop11-23H2.cs
Expand All @@ -20,8 +20,8 @@
[assembly:AssemblyCopyright("© Markus Scholtes 2023")]
[assembly:AssemblyTrademark("")]
[assembly:AssemblyCulture("")]
[assembly:AssemblyVersion("1.15.0.0")]
[assembly:AssemblyFileVersion("1.15.0.0")]
[assembly:AssemblyVersion("1.16.0.0")]
[assembly:AssemblyFileVersion("1.16.0.0")]

// Based on http://stackoverflow.com/a/32417530, Windows 10 SDK, github project Grabacr07/VirtualDesktop and own research

Expand Down Expand Up @@ -486,8 +486,19 @@ public void Remove(Desktop fallback = null)

public static void RemoveAll()
{ // remove all desktops but visible
// ***** To reimplement since not supported by API anymore
// DesktopManager.VirtualDesktopManagerInternal.SetDesktopIsPerMonitor(true);
int desktopcount = DesktopManager.VirtualDesktopManagerInternal.GetCount();
int desktopcurrent = DesktopManager.GetDesktopIndex(DesktopManager.VirtualDesktopManagerInternal.GetCurrentDesktop());

if (desktopcurrent < desktopcount-1)
{ // remove all desktops "right" from current
for (int i = desktopcount-1; i > desktopcurrent; i--)
DesktopManager.VirtualDesktopManagerInternal.RemoveDesktop(DesktopManager.GetDesktop(i), DesktopManager.VirtualDesktopManagerInternal.GetCurrentDesktop());
}
if (desktopcurrent > 0)
{ // remove all desktops "left" from current
for (int i = 0; i < desktopcurrent; i++)
DesktopManager.VirtualDesktopManagerInternal.RemoveDesktop(DesktopManager.GetDesktop(0), DesktopManager.VirtualDesktopManagerInternal.GetCurrentDesktop());
}
}

public void Move(int index)
Expand Down Expand Up @@ -2531,7 +2542,7 @@ private static void SwapDesktops(int SwapIndex1, int SwapIndex2)

static void HelpScreen()
{
Console.WriteLine("VirtualDesktop.exe\t\t\t\tMarkus Scholtes, 2023, v1.15\n");
Console.WriteLine("VirtualDesktop.exe\t\t\t\tMarkus Scholtes, 2023, v1.16\n");

Console.WriteLine("Command line tool to manage the virtual desktops of Windows 11.");
Console.WriteLine("Parameters can be given as a sequence of commands. The result - most of the");
Expand Down
8 changes: 4 additions & 4 deletions VirtualDesktop11.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Author: Markus Scholtes, 2023
// Version 1.14, 2023-08-29
// Version 1.16, 2023-09-17
// Version for Windows 11 22H2
// Compile with:
// C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe VirtualDesktop11.cs
Expand All @@ -20,8 +20,8 @@
[assembly:AssemblyCopyright("© Markus Scholtes 2023")]
[assembly:AssemblyTrademark("")]
[assembly:AssemblyCulture("")]
[assembly:AssemblyVersion("1.14.0.0")]
[assembly:AssemblyFileVersion("1.14.0.0")]
[assembly:AssemblyVersion("1.16.0.0")]
[assembly:AssemblyFileVersion("1.16.0.0")]

// Based on http://stackoverflow.com/a/32417530, Windows 10 SDK, github project Grabacr07/VirtualDesktop and own research

Expand Down Expand Up @@ -2527,7 +2527,7 @@ private static void SwapDesktops(int SwapIndex1, int SwapIndex2)

static void HelpScreen()
{
Console.WriteLine("VirtualDesktop.exe\t\t\t\tMarkus Scholtes, 2023, v1.14\n");
Console.WriteLine("VirtualDesktop.exe\t\t\t\tMarkus Scholtes, 2023, v1.16\n");

Console.WriteLine("Command line tool to manage the virtual desktops of Windows 11.");
Console.WriteLine("Parameters can be given as a sequence of commands. The result - most of the");
Expand Down
Loading

0 comments on commit 546b673

Please sign in to comment.