Virtual Desktop Hotkey Cycle
Makes Win+Ctrl+Left and Win+Ctrl+Right virtual desktop shortcuts loop through ends.
Author: Amrsatrio
This simple mod makes Win+Ctrl+Left and Win+Ctrl+Right cycle to the last/first desktops when the current virtual desktop is the first/last, respectively.
Compatibility
- Version: Windows 10 1507 and up
- Architecture: x64, ARM64
Tested on Windows 11 24H2 x64 and ARM64.
How it works
Windows normally calls CVirtualDesktopCollection::GetAdjacentVirtualDesktop with a reference to the current virtual desktop. This method is implemented in twinui.pcshell.dll on Windows builds 17763 (1809) and newer, and in twinui.dll on builds prior to 17763. When there is no desktop in the requested direction (for example, pressing Win+Ctrl+Right on the last desktop), the function returns TYPE_E_OUTOFBOUNDS, which prevents further navigation.
This mod hooks GetAdjacentVirtualDesktop and watches for that out-of-bounds result:
- The original function is called first with the current desktop (
pReference).
- If it fails with
TYPE_E_OUTOFBOUNDS, the mod checks how many virtual desktops exist.
- If more than one desktop is present, the function is called again with
pReference set to nullptr.
When pReference is nullptr, Windows interprets the request as:
- Right / Down: return the first virtual desktop
- Left / Up: return the last virtual desktop
By reissuing the call this way, the mod effectively turns the standard virtual desktop hotkeys into a loop, allowing seamless cycling from end to beginning and vice versa.