This is just an idea for something to try and adapt... not tested.
As long as the script is running it just saves the virtual desktop active in a variable, don't need an ini file necessarily.
The script either has to be started with virtual desktop #1 active or it has to force a sync. The forcing function assumes you can press ctrl+win+left as many times as you want and it will not loop past the first virtual desktop once it gets there.
The shortcut keys trigger on the default windows keys but don't capture them (i.e., tilde ~ lets the keystroke go through). So it would track the keyboard if you were using the keyboard, and if you were using the mouse you could assign the mouse to one shortcut key or another.
You could also add a custom duplicate shortcut for one or both directions... showing this as ctrl+alt+F8, for example in case your mouse button needs to be assigned to something other than the default windows keys for switching between desktops.
#NoEnv
#Persistent
numDesktops := 3 ; set to match number of virtual desktops
if forceSyncAtStartup := True ; set to False to disable sync on startup
SendInput % "^#{Left" (numDesktops-1) "}"
vDesktop := 1 ; this must match the virtual desktop active when program starts if a sync isn't forced
return
^!F8:: ; random/custom shortcut for the mouse if desired
~^#Left::
vDesktop -= 1
if (vDesktop=0) {
vDesktop := numDesktops
sleep 20 ; optional for better reliability
; use this if no delay needed for reliable operation
SendInput % "^#{Right " (numDesktops-1) "}
; use this type of setup if a delay is needed
; Loop, % (numDesktops-1) {
; SendInput ^#{Right}
; sleep 100 ; adjust for reliability
; }
}
return
~^#Right::
vDesktop += 1
sleep 20
if (vDesktop=(numDesktops+1)) {
vDesktop := 1
SendInput % "^#{Left" (numDesktops-1) "}"
}
return