6

Let's say I have three virtual desktops. I know I can navigate through them using:

ctrl + windows + left | right

However, is there a way to make it cycle back through to the beginning if I reach the end? So that if I am on desktop 3 "ctrl + windows + right" will take me to desktop 1?

I know this may be possible with an AutoHotkey script. But I don't know how to make that work.

The reason I need this to work this way is because I intend to map this functionality to a mouse I have just bought (it has extra buttons).Currently I need to use two buttons so that I can move backwards and forwards between desktops. I would rather just one button was needed. Hopefully this information helps.

Thanks

  • You can use IniRead and IniWrite to know which particular desktop you're currently using every time you press ctrl + windows + left | right. I personally recommend Windows 10 Virtual Desktop Enhancer. – user3419297 Feb 8 '17 at 6:46
  • That does add quite a bit of functionality to Windows, so I'll definitely use this. But this still doesn't answer my question. I need the desktops to behave as a 'loop' or 'circuit' as opposed to 'A to B'. The main reason I need this to work like this is because I am in the process of mapping useful functions to a mouse I have just bought. I currently have 'next desktop' and 'previous desktop' mapped to two buttons, but I'd rather just have one button for virtual desktop navigation. Hopefully this background information helps. – Caedan Lavender Feb 8 '17 at 8:39
  • If you use both (IniRead/IniWrite and Virtual Desktop Enhancer) you can easily switch to the first desktop if you are on the last desktop by pressing 'next desktop' on your mouse. – user3419297 Feb 8 '17 at 9:26
  • I still have no idea how to do this. I said that I know this is possible with AutoHotKey, but that I do not know how to make this work. – Caedan Lavender Feb 8 '17 at 23:21
0

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  
  • Thanks! Looks promising. I'll give it a try later today. :) – Caedan Lavender Feb 9 '17 at 19:03
0

Another option is to use Finestra Virtual Desktops which does this cycling by default and the hotkeys are configurable.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.