Hey there
This is pretty easy. In fact I've been trying to solve the exact same problem as described in this post:
https://forums.stardock.com/481249/Fences-Desktop-Pages-vs-Windows-10-Desktops
I can't post in that thread as it's now locked but figured that the solution also fits your problem.
The answer lies in combining Windows 10 Virtual Desktops, Windows 10 Virtual Desktop Enhancer aka VDE (https://github.com/sdias/win-10-virtual-desktop-enhancer), AHK (https://autohotkey.com) and Fences' Desktop pages.
If one was able to automagically switch to the Desktop page that (conceptually) corresponds to a Virtual Desktop, then whenever switching between virtual desktops means that one would see the corresponding Fences configuration. Clear as mud? Pragmatically, when I'm in my 'Standard' virtual desktop I want to see my standard (first) desktop page and when I'm in my 'Development' virtual desktop I want to see my development (second) desktop page.
This post is not designed to explain what Window 10 Virtual Desktops or Fences' Desktop Pages are, so if you're unfamiliar with these look up the appropriate Windows 10 or Fences documentation.
The lynchpin in all this is the Windows 10 Virtual Desktop Enhancer which extends the core functionality of virtual desktops. Among other things, it allows you to name your desktops, flash up a tooltip to show which desktop you're in, change the wallpaper for each desktop etc... The cool thing is that it can be run via AHK and allows you to run a program or script when switching to or from a desktop.
Unfortunately Fences doesn't seem to have an API, let you run scripts or command line arguments (a bit slack really IMHO) but what it does provide is switch desktop pages left and right by pressing Alt+Left or Alt+Right.
As Fences only supports moving to the left or right desktop page (there is currently no support for a hotkey for instance, to go straight to desktop page 4 or desktop page 7 etc.) this solution is limited to supporting only 2 virtual desktops (the left and the right).
So what we want is a solution that when VDE detects a change to the left or right virtual desktop, it also switches to the appropriate Fences' Desktop Page.
Here is the solution I came up with:
- Create two virtual desktops
- Create two Fences' desktop pages with the Fences as per your requirements
- Make sure that Fences' Desktop Pages is enabled and that switch pages with Alt+Left / Alt+Right is also enabled
- Install AutoHotKey
- Download and set-up Windows 10 Virtual Desktop Enhancer, using AHK as the deployment mechanism (deets in the docs/installation.md file)
- Name your desktops in the settings.ini file of VDE (optional):
Code: vbscript
- [DesktopNames]
- 1=Standard
- 2=Development
- Create two new .ahk files with the following (as below for left, change the script to !{Right} for right):
Code: vbscript
- WinActivate Program Manager
- Send !{Left}
- Exit
- Add the appropriate references to the settings.ini file for the two AHK scripts you created:
Code: vbscript
- [RunProgramWhenSwitchingToDesktop]
- 1=D:\Temp\Left.ahk
- 2=D:\Temp\Right.ahk
The thing that's really elegant about this solution is that it doesn't matter how you switch between virtual desktops, whether it's via hotkeys, the desktop manager, the status tray icon or even by switching to a program that is already open on the other virtual desktop, VDE and the AHK script makes sure that the correct desktop page is shown. (This won't stop you manually changing the desktop page that is currently shown without changing the virtual desktop but will ensure that when you switch desktops you will see the correct desktop page again.)
I would love to be able to support more than two desktops here, but the limitation is with Fences' support for only moving left or right. Once Stardock enables hotkeys for Desktop Pages (e.g. Ctrl+Alt+4, Ctrl+Alt+7 etc.) it would be easy to support them with a single, more advanced script than I was willing to create in 15 minutes this afternoon (gee this post has taken much longer than finding the solution!)
Anyway, I hope this helps. If you need any assistance I have an email subscription to this post and will try to help out.
Cheers,
Paul Sorauer