100

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 or Windows 11.

UPDATE SOLUTION

  1. (Step not needed for Windows 11 - only for Window10 users) 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. (Only Windows 11 users) replace VirtualDesktopAccessor.dll with file from https://github.com/skottmckay/VirtualDesktopAccessor/tree/master/x64/Release

  2. Run virtual-desktop-enhancer.exe as administrator.

  3. Use shortcuts win+1/2/3/n (where n is a number of your created virtual desktops) to switch between virtual desktops directly and win+`~ for "expose" effect.

8
  • 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, 2015 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, 2015 at 16:45
  • 1
    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. Dec 26, 2016 at 23:42
  • Update: version (0.9.1) works without any problem on ver. 1903 from may 2019 May 27, 2019 at 2:33
  • 3
    cannot believe it is 2023, and it is still no native way to switch between specific workspace. has like no one requested it to their devs?
    – starcorn
    Feb 15, 2023 at 18:50

10 Answers 10

44

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
7
  • 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, 2015 at 11:25
  • 38
    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, 2015 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, 2016 at 7:25
  • 16
    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, 2018 at 0:15
  • 7
    Downvoted for not answering the question. Apr 23, 2020 at 21:15
19

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!

2
  • 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, 2016 at 7:50
  • caps lock is the most convenient - unfortunately for me it works correctly only 9 times out of 10 or 4/5... can't think of what key to change it to, maybe i should sacrifice a right alt or right ctrl, if that works
    – Mikey
    May 17, 2020 at 14:53
18

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}
}
7
  • Also you can add #NoTrayIcon at the start of the script if you don't like the little green icon in the system tray. Mar 9, 2016 at 16:44
  • 1
    Oh... I droptic already created a better script that gets the active and total desktops from the registry. Good idea! Mar 10, 2016 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 Mar 10, 2016 at 10:29
  • Awesome man!! Thanks for sharing. I just change #1 with ^1 I like to use Ctrl instead Win key. May 12, 2016 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, 2017 at 13:01
7

This method does not actually change the existing keyboard shortcuts because the original shortcuts stay active, but it allows you to define other shortcuts according to your needs.

For that, I have used the tool Keyboard Manager from the Microsoft PowerToys bundle of productivity utilities. It allows you to remap individual keys as well as define arbitrary keyboard shortcuts and map them to other keys or shortcuts.

I have remapped the following shortcuts:

  • Ctrl+Alt+Left to Ctrl+Win+Left
  • Ctrl+Alt+Right to Ctrl+Win+Right

Now, I can use Ctrl+Alt+Left and Ctrl+Alt+Right to switch desktops.

The PowerToys bundle contains a few other useful utilities so it's worth it anyway. And it's open-source!

5
  • This answer should be downvoted because this does not answer the original question i.e. how to click Win + <number> to switch desktops
    – Banoona
    May 8, 2021 at 8:47
  • 1
    @Banoona True, but it's relevant for "how to change shortcut key for switching between virtual desktops in windows 10". I found this question looking for a way to do the exact remapping mentioned here, and it solved my problem. Nov 1, 2021 at 13:28
  • 1
    This is exactly what I was looking for, thanks!
    – Flaiming
    Jun 27, 2022 at 12:20
  • 2
    +1 for powertoys. OSS developed by Microsoft, keyboard re-mapping works flawlessly for me so far
    – panepeter
    Aug 24, 2022 at 14:53
  • Brilliant, thanks a bunch! Upvoted, because this as exactly what I came to this question for!
    – stolsvik
    Jan 15 at 15:20
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
  • 1
    This is nice for if you have only two virtual desktops, but I have three. Dec 28, 2015 at 19:46
0

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.

2
  • 1
    F1 is help on every windows machine I have ever used. You answer makes no sense.
    – DavidPostill
    Nov 10, 2015 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. Dec 28, 2015 at 19:44
0

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

3
  • 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, 2016 at 16:41
  • 1
    However it works perfectly under Windows 8.1 and 10.
    – dblacha
    Apr 13, 2016 at 9:00
  • Worth noting that 4 desktops is the max supported by the tool
    – Mark Sowul
    Dec 16, 2023 at 17:14
0

This PowerShell script: https://www.powershellgallery.com/packages/VirtualDesktop lets you switch to a numbered virtual desktop. It works on Windows 10 & 11. Use Autohotkey or another key binding solution to execute 'Switch-Desktop 0' (or 1 or 2 or whatever) in PowerShell to do what you're asking (I know this question is very old, but it seems to be a common problem still, and I don't see this solution mentioned anywhere).

-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

2
  • 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, 2018 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, 2018 at 22:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .