diff --git a/Changes.txt b/Changes.txt index e9c1f26..e2ddf48 100644 --- a/Changes.txt +++ b/Changes.txt @@ -1,5 +1,8 @@ Changes: +Version 1.15, 2023-09-02 +- bug fix for Win 11 22H2 Build 22621.2215 + Version 1.14, 2023-08-29 - version for Windows 11 22H2.2215 and up called VirtualDesktop11-23H2.cs - removed VirtualDesktopInsider.cs diff --git a/README.md b/README.md index fcf54a8..a424dd1 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,8 @@ C# command line tool to manage virtual desktops in Windows 10 and Windows 11 **Pre-compiled binaries in Releases now** -**Version 1.14, 2023-08-29** -- version for Windows 11 22H2.2215 and up called VirtualDesktop11-23H2.cs -- removed VirtualDesktopInsider.cs +**Version 1.15, 2023-09-02** +- bug fix for Win 11 22H2 Build 22621.2215, 2023/09/02 (look for a powershell version here: https://github.com/MScholtes/PSVirtualDesktop or here: https://www.powershellgallery.com/packages/VirtualDesktop) diff --git a/ReadMe.txt b/ReadMe.txt new file mode 100644 index 0000000..ae30b54 --- /dev/null +++ b/ReadMe.txt @@ -0,0 +1,113 @@ +https://github.com/MScholtes/VirtualDesktop/ + + +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 + +(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 + + +Generate: + Compile with Compile.bat (no visual studio needed, but obviously Windows 10 or 11) + +Description: + Command line tool to manage the virtual desktops of Windows 10 and 11. + Parameters can be given as a sequence of commands. The result - most of + thetimes the number of the processed desktop - can be used as input for the + next parameter. The result of the last command is returned as error level. + Virtual desktop numbers start with 0. + +Parameters (leading / can be omitted or - can be used instead): + +/Help /h /? this help screen. +/Verbose /Quiet enable verbose (default) or quiet mode (short: /v and /q). +/Break /Continue break (default) or continue on error (short: /b and /co). +/List list all virtual desktops (short: /li). +/Count get count of virtual desktops to pipeline (short: /c). +/GetDesktop: get number of virtual desktop or desktop with text in name to pipeline (short: /gd). +/GetCurrentDesktop get number of current desktop to pipeline (short: /gcd). +/Name[:] set name of desktop with number in pipeline (short: /na). +/Wallpaper[:] set wallpaper path of desktop with number in pipeline (short: /wp)(only VirtualDesktop11.exe). +/AllWallpapers: set wallpaper path of all desktops (short: /awp)(only VirtualDesktop11.exe). +/IsVisible[:] is desktop number , desktop with text in name or with number in pipeline visible (short: /iv)? Returns 0 for visible and 1 for invisible. +/Switch[:] switch to desktop with number , desktop with text in name or with number in pipeline (short: /s). +/Left switch to virtual desktop to the left of the active desktop (short: /l). +/Right switch to virtual desktop to the right of the active desktop (short: /ri). +/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[:] remove desktop number , desktop with text in name or desktop with number in pipeline (short: /r). +/RemoveAll remove all desktops but visible (short: /ra)(only VirtualDesktop11.exe). +/SwapDesktop: swap desktop in pipeline with desktop number , desktop with text in name or desktop with number in pipeline (short: /sd). +/InsertDesktop: insert desktop number or desktop with text in name before desktop in pipeline or vice versa (short: /id)(not VirtualDesktop11.exe). +/MoveDesktop: move desktop in pipeline to desktop number or desktop with text in name (short: /md)(only VirtualDesktop11.exe). +/MoveWindowsToDesktop: move windows on desktop in pipeline to desktop number or desktop with text in name (short: /mwtd). +/MoveWindow: move process with name or id to desktop with number in pipeline (short: /mw). +/MoveWindowHandle: move window with text in title or handle to desktop with number in pipeline (short: /mwh). +/MoveActiveWindow move active window to desktop with number in pipeline (short: /maw). +/GetDesktopFromWindow: get desktop number where process with name or id is displayed (short: /gdfw). +/GetDesktopFromWindowHandle: get desktop number where window with text in title or handle is displayed (short: /gdfwh). +/IsWindowOnDesktop: check if process with name or id is on desktop with number in pipeline (short: /iwod). Returns 0 for yes, 1 for no. +/IsWindowHandleOnDesktop: check if window with text in title or handle is on desktop with number in pipeline (short: /iwhod). Returns 0 for yes, 1 for no. +/ListWindowsOnDesktop[:] list handles of windows on desktop number , desktop with text in name or desktop with number in pipeline (short: /lwod). +/CloseWindowsOnDesktop[:] close windows on desktop number , desktop with text in name or desktop with number in pipeline (short: /cwod). +/PinWindow: pin process with name or id to all desktops (short: /pw). +/PinWindowHandle: pin window with text in title or handle to all desktops (short: /pwh). +/UnPinWindow: unpin process with name or id from all desktops (short: /upw). +/UnPinWindowHandle: unpin window with text in title or handle from all desktops (short: /upwh). +/IsWindowPinned: check if process with name or id is pinned to all desktops (short: /iwp). Returns 0 for yes, 1 for no. +/IsWindowHandlePinned: check if window with text in title or handle is pinned to all desktops (short: /iwhp). Returns 0 for yes, 1 for no. +/PinApplication: pin application with name or id to all desktops (short: /pa). +/UnPinApplication: unpin application with name or id from all desktops (short: /upa). +/IsApplicationPinned: check if application with name or id is pinned to all desktops (short: /iap). Returns 0 for yes, 1 for no. +/Calc: add to result, negative values are allowed (short: /ca). +/WaitKey wait for key press (short: /wk). +/Sleep: wait for milliseconds (short: /sl). + +Hint: Instead of a desktop name you can use LAST or *LAST* to select the last virtual desktop. +Hint: Insert ^^ somewhere in window title parameters to prevent finding the own window. ^ is removed before searching window titles. + + +Examples: + +Virtualdesktop.exe /LIST + +Virtualdesktop.exe "-Switch:Desktop 2" + +Virtualdesktop.exe -New -Switch -GetCurrentDesktop + +Virtualdesktop.exe Q N /MOVEACTIVEWINDOW /SWITCH + +Virtualdesktop.exe sleep:200 gd:1 mw:notepad s + +Virtualdesktop.exe /Count /continue /Remove /Remove /Count + +Virtualdesktop.exe /Count /Calc:-1 /Switch + +VirtualDesktop.exe -IsWindowPinned:cmd +if ERRORLEVEL 1 VirtualDesktop.exe PinWindow:cmd + +Virtualdesktop.exe -GetDesktop:*last* "-MoveWindowHandle:note^^pad" + +for /f "tokens=4 delims= " %i in ('VirtualDesktop.exe c') do @set DesktopCount=%i +echo Count of desktops is %DesktopCount% +if %DesktopCount% GTR 1 VirtualDesktop.exe REMOVE diff --git a/VirtualDesktop11-23H2.cs b/VirtualDesktop11-23H2.cs index ea9b61d..0e505f7 100644 --- a/VirtualDesktop11-23H2.cs +++ b/VirtualDesktop11-23H2.cs @@ -1,5 +1,5 @@ // Author: Markus Scholtes, 2023 -// Version 1.14, 2023-08-29 +// Version 1.15, 2023-08-29 // Version for Windows 11 22H2.2215 and up // Compile with: // C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe VirtualDesktop11-23H2.cs @@ -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.15.0.0")] +[assembly:AssemblyFileVersion("1.15.0.0")] // Based on http://stackoverflow.com/a/32417530, Windows 10 SDK, github project Grabacr07/VirtualDesktop and own research @@ -172,7 +172,7 @@ internal interface IVirtualDesktopManagerInternal [PreserveSig] int GetAdjacentDesktop(IVirtualDesktop from, int direction, out IVirtualDesktop desktop); void SwitchDesktop(IVirtualDesktop desktop); - void SwitchDesktopAndMoveForegroundView(IVirtualDesktop desktop); +// void SwitchDesktopAndMoveForegroundView(IVirtualDesktop desktop); IVirtualDesktop CreateDesktop(); void MoveDesktop(IVirtualDesktop desktop, int nIndex); void RemoveDesktop(IVirtualDesktop desktop, IVirtualDesktop fallback); @@ -2531,7 +2531,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.15\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");