58

In linux I use a shortcut to switch between 4 workspaces: win+1/2/3/4.

I would like to have something like this in Windows 10.

UPDATE SOLUTION 2017, WINDOWS 10x64

  1. Update your windows version to most recent through this updater. You may also need Visual C++ Redistributable for Visual Studio 2015
  2. Download and unzip this Windows 10 Virtual Desktop Enhancer (0.9.1) works for me.
  3. Change content of file settings.ini to
[KeyboardShortcuts]
Switch=LWin
Move=LAlt, Shift, Ctrl
MoveAndSwitch=LAlt, Shift
Previous=Left
Next=Right
PlusTen=
  1. Run virtual-desktop-enhancer.exe as administrator.
  • 2
    This is a valid question. In Windows 10, you are allowed to switch between virtual desktop views. This is very similar to how Mac OSX and Linux have let you switch in the past. – Geruta Jul 14 '15 at 11:21
  • Maybe there's a command prompt or powershell command that can switch to a specific desktop? (If so then it should be easy to make a batch script or something and then just use autohotkey to redirect win+1/2/3/4 to said batch script) otherwise, when a program is switched focus to, windows 10 will switch to the desktop that program is on. So this means if there is a way to open a program on a specific desktop it might be possible to do what I described above with some trickery based on that function instead. – Cestarian Oct 29 '15 at 16:45
  • Note that, by default, in Windows 10, WIN + 1/2/3/4... opens, switches to, or minimises the window in the corresponding numbered position in the task bar. For example, if I have Chrome pinned to the taskbar in position 1 and it is currently closed, WIN + 1 will open it. Pressing again will minimise it, and pressing again will bring the window back. I can combine this with other shortcuts; now pressing WIN + SHIFT + 1 would open a new Chrome window, for example. – Ninjakannon Dec 26 '16 at 23:42
41

What you need is as follows:

  • Snapping window: WIN+LEFT or RIGHT (can be used with UP or DOWN to get into quadrants)
  • Switch to recent window: Alt+Tab (unchanged) – Hold shows new Task view window view, let go and switches to app.
  • Task view: WIN+Tab – New Task view opens up and stays open.
  • Create new virtual desktop: WIN+Ctrl+d
  • Close current virtual desktop: WIN+Ctrl+F4
  • Switch virtual desktop: WIN+Ctrl+LEFT or RIGHT
  • So the difference here is that you first must create the 2nd desktop with (WIN + CTRL + D), and then switch to it with (WIN + CTRL + RIGHT) – Geruta Jul 14 '15 at 11:25
  • 16
    Still lacking a way to switch to a specific desktop with one shortcut (i.e. straight from desktop 1 to desktop 3) – Cestarian Oct 29 '15 at 17:57
  • Ufortunately, WIN CTRL RIGHT does not work on a Samsung Ativ 9+. LEFT does work, but there is no wrap around between e.g. 3 virtual desktops. Anyone with a better experience? – carl Sep 22 '16 at 7:25
  • 2
    Downvoted for not answering the question: it asks how to change it, specifically to be able to use a desktop number to switch to. – Luc Aug 18 '18 at 0:15
14

I think I just built exactly what you're looking for. I use a window manager on linux and wanted to use hotkeys in a similar way on Windows.

https://github.com/pmb6tz/windows-desktop-switcher

My script uses CapsLock because it's more convenient for me, but you could easily configure it to work for you. There's probably a bug or two in there but in general I've found it to be pretty solid. Hope this helps you out!

  • That script just works perfectly, after I commented out the last paragraph of the code. Thank you for sharing. I have made a pull request with the changes I made to the code. – David May 2 '16 at 7:50
11

I just made a script for autohotkey that accomplishes this in Windows 10 for up to 10 desktops.

How to get it working:

Download and install autohotkey. Copy and paste the code bellow into notepad and save it with the file extension .ahk

I suggest making a shortcut of this file in your startup folder so it runs when Windows starts.

DEFAULT HOTKEYS:

Switch desktop: WIN+DESKTOP NUMBER (0 = desktop number 10)

New desktop: CTRL+WIN+D

Close desktop: CTRL+WIN+F4

Display desktop state: WIN+'

IMPORTANT:

In order for it to work you must ONLY use hotkeys for opening, closing, and changing desktops because the script listens for these hotkeys to know the current and total number of desktops.

If you do create, close, or change desktops via the WIN+TAB menu with the mouse the script will stop working. In order to get it working again you will need to edit the first two lines to reflect the current state of your desktops. (desktopcount/currentdesktop)

This doesn't mean you can't use the WIN+TAB screen as an overview of your current desktops. You can actually use it in combination of the hotkeys to organize your desktops. Yes, the hotkeys still work when the windows task viewer is open! (WIN+TAB) Just DO NOT use the mouse!!!

Also, wait for the script to load after Windows startup before creating new desktops or it will not work. This could take a moment depending on how many startup programs you have.

Ok, I added one more thing to make it easier to re-sync the script with your desktop state. There is now a hotkey that will display the state the script believes the desktops to be in so all you have to do is adjust your desktops with the mouse to fit the script and it will be all synced up again! For me with a Swiss keyboard it worked out nicely having the '? key next to 0 and it makes sense with a ? on it, but on other keyboards you may wish to change this which can be done easily by changing the line right after the hotkey for 0/10 (starting with #') to whatever you like.

Actually, I just realized.... as long as the Desktop Count is correct than creating a new desktop will automatically re-sync the Current Desktop value.

(The lines starting with ; are comments and do not affect the script)

Code:

#NoTrayIcon
;If the script stops working:
;Change the following values to reflect your current desktop state and reload the script.
;Remember to change them back to 1 after reloading the script if you have it set to start with Windows

desktopcount := 1
currentdesktop := 1

;You can change the hotkeys for creating, closing, and switching desktops bellow.
;The current hotkeys are CTRL+WIN+D for new desktop, CTRL+WIN+F4 to close desktop
;and WIN+NUMBER for switching desktops.
;For example, to change the hotkey for new desktop replace ^#D bellow with the desired hotkey.
;Refer to the autohotkey documentation for a full list of symbols refering to modifier keys,
;as you can see ^ is CTRL and # is WIN key.
;If you wanted to change the switch desktop from WIN key to CTRL for example you would have
;to replace the # before each number to a ^

^#D::NewDesktop()
^#F4::CloseDesktop()
#1::SwitchDesktop(1)
#2::SwitchDesktop(2)
#3::SwitchDesktop(3)
#4::SwitchDesktop(4)
#5::SwitchDesktop(5)
#6::SwitchDesktop(6)
#7::SwitchDesktop(7)
#8::SwitchDesktop(8)
#9::SwitchDesktop(9)
#0::SwitchDesktop(10)
#'::MsgBox Desktop Count = %desktopcount%`nCurrent Desktop = %currentdesktop%

;Do not change anything after this line, unless you know what you are doing ;)
;-----------------------------------------------------------------------------------------------
SwitchDesktop(desktop)
{

    global desktopcount
    global currentdesktop
    desktopdiff := desktop - currentdesktop
    if (desktop > desktopcount)
    {
        return
    }
    if (desktopdiff < 0)
    {
        desktopdiff *= -1
        Loop %desktopdiff%
        {
        Send ^#{Left}
        }   
    }
    else if (desktopdiff > 0)
    {
        Loop %desktopdiff%
        {
        Send ^#{Right}
        }
    }
    currentdesktop := desktop
}

NewDesktop()
{
    global desktopcount
    global currentdesktop
    if (desktopcount > 9)
    {
        return
    }
    desktopcount ++
    currentdesktop := desktopcount
    Send ^#d
}

CloseDesktop()
{
    global desktopcount
    global currentdesktop
    desktopcount --
    if (currentdesktop != 1)
    {
        currentdesktop --
    }
    Send ^#{f4}
}
  • Also you can add #NoTrayIcon at the start of the script if you don't like the little green icon in the system tray. – OptimistPrime Mar 9 '16 at 16:44
  • 1
    Oh... I droptic already created a better script that gets the active and total desktops from the registry. Good idea! – OptimistPrime Mar 10 '16 at 9:46
  • 1
    Although, please note that the registry path could be different per user/computer. I don't know what has influence on this but my path for current desktop id was in a folder with the number 2, not 1: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SessionInfo\2\VirtualDesktops – OptimistPrime Mar 10 '16 at 10:29
  • Awesome man!! Thanks for sharing. I just change #1 with ^1 I like to use Ctrl instead Win key. – Gueorgui Obregon May 12 '16 at 20:10
  • This script is AWESOME! The only thing with me is that I've got some capslock remapping already, and I would like to add this to my script. Sadly, it doesn't work. It only works if I remove the following line (before the script): CapsLock::Ctrl Any ideas how can I fix this? Removing this line works, but having CAPSLOCK act as Ctrl is very inportant to me... – bitstream Jul 26 '17 at 13:01
1

For example i want to set Page Down for next desktop and Page Up for previous desktop After i install AutoHotkey , i create a new AutoHotKey Script and add to it this codes and save it then run script

PgDn::^#Right ;Next Desktop
return 

PgUp::^#Left ;Previous Desktop
return 

and it will work nice :)

Update: Sometimes above code doesn't work and you must click at a point.then i changed it to this:

PgDn::
   {
      MouseGetPos,,,win
      WinGetClass, class, ahk_id %win%
      If class in Progman,WorkerW
         send {Click}^#{Right}  
      else
         send ^#{Right}  ; Next  Desktop  
      return
    }

PgUp::
    {
       MouseGetPos,,,win
       WinGetClass, class, ahk_id %win%
       If class in Progman,WorkerW
          send {Click}^#{Left}
       else
          send ^#{Left}  ; Previous Desktop  
       return
    }
0

Ok, partial solution... because I don't know how to go straight to selected virtual desktop:

This program autohotkey with script:

#NoTrayIcon
#2::^#Right
#1::^#Left
#3::Return
#4::Return
  • 1
    This is nice for if you have only two virtual desktops, but I have three. – Michael Beijer Dec 28 '15 at 19:46
-1

I did an inplace upgrade directly from Windows 7 to 10 and struggled with using the Windows+CTRL+Arrow keys to switch between desktops as they would just not work. However the solution was simple in my case - Use the single Function keys (F1, F2, F3 etc) to easily switch between Virtual desktops. Now I don't know if this is specific to my HP laptop or part of the released version but it is both elegant and simple. I'm assuming as long as you don't have the Function keys mapped for some other purpose it should work for you as well.

  • 1
    F1 is help on every windows machine I have ever used. You answer makes no sense. – DavidPostill Nov 10 '15 at 12:26
  • This is definitely not my experience on my Dell Precision laptop (with Win 10). Win+Ctrl+F1/F2/F3 do nothing. Although it'd be great if they did. – Michael Beijer Dec 28 '15 at 19:44
-1

I'm using the Desktops v2.0 from SysInternals and I have 4 desktops under a single key: F1,F2,F3,F4 (is anyone using F1 for invoking the help, really?). For me, the Windows 10 solution is unusable due to three keys shortcuts.

Desktops v2.0 official: https://technet.microsoft.com/en-us/sysinternals/cc817881.aspx

  • This product does not support Windows 8 and above. How do I know this, because I specifically recall, a question in the past asking about said program on Windows 8 – Ramhound Apr 12 '16 at 16:41
  • 1
    However it works perfectly under Windows 8.1 and 10. – dblacha Apr 13 '16 at 9:00
-2

The AHK script given by OptimistPrime: https://superuser.com/a/1050690/184229 does not work for me (keys have no effect), but

this one works just fine: https://github.com/pmb6tz/windows-desktop-switcher/blob/master/desktop_switcher.ahk

  • Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change. – DavidPostill Dec 22 '18 at 16:21
  • I would have preferred to comment on the answer I referred to, but was not allowed. If you had had a closer look at my answer you would have noticed that: 1. it does give an answer the original question 2. it would be very verbose and not really adequate to copy the contents of the second link I gave. – dvo Dec 23 '18 at 22:24

protected by Community Feb 12 '17 at 5:17

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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