How to change shortcut key for switching between virtual desktops in windows 10?

65

20

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.

Dariusz Filipiak

Posted 2015-07-14T09:24:19.620

Reputation: 767

2This 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 – 2015-07-14T11:21:47.143

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 – 2015-10-29T16:45:33.833

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 – 2016-12-26T23:42:50.297

Update: version (0.9.1) works without any problem on ver. 1903 from may 2019 – Dariusz Filipiak – 2019-05-27T02:33:54.137

Answers

42

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

Geruta

Posted 2015-07-14T09:24:19.620

Reputation: 1 185

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 – 2015-07-14T11:25:39.897

19Still lacking a way to switch to a specific desktop with one shortcut (i.e. straight from desktop 1 to desktop 3) – Cestarian – 2015-10-29T17:57:42.620

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 – 2016-09-22T07:25:24.680

3Downvoted for not answering the question: it asks how to change it, specifically to be able to use a desktop number to switch to. – Luc – 2018-08-18T00:15:58.533

16

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!

droptic

Posted 2015-07-14T09:24:19.620

Reputation: 161

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 – 2016-05-02T07:50:01.097

12

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}
}

OptimistPrime

Posted 2015-07-14T09:24:19.620

Reputation: 121

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 – 2016-03-09T16:44:42.230

1Oh... I droptic already created a better script that gets the active and total desktops from the registry. Good idea! – OptimistPrime – 2016-03-10T09:46:37.700

1Although, 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 – 2016-03-10T10:29:12.920

Awesome man!! Thanks for sharing. I just change #1 with ^1 I like to use Ctrl instead Win key. – Gueorgui Obregon – 2016-05-12T20:10:35.113

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 – 2017-07-26T13:01:44.290

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
    }

AliOsat Mostafavi

Posted 2015-07-14T09:24:19.620

Reputation: 11

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

Dariusz Filipiak

Posted 2015-07-14T09:24:19.620

Reputation: 767

1This is nice for if you have only two virtual desktops, but I have three. – Michael Beijer – 2015-12-28T19:46:31.563

-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

dblacha

Posted 2015-07-14T09:24:19.620

Reputation: 1

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 – 2016-04-12T16:41:54.893

1However it works perfectly under Windows 8.1 and 10. – dblacha – 2016-04-13T09:00:07.003

-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.

Grey Warbler

Posted 2015-07-14T09:24:19.620

Reputation: 1

1F1 is help on every windows machine I have ever used. You answer makes no sense. – DavidPostill – 2015-11-10T12:26:17.533

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 – 2015-12-28T19:44:52.033

-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

dvo

Posted 2015-07-14T09:24:19.620

Reputation: 37

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 – 2018-12-22T16:21:11.830

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.
  3. < – dvo – 2018-12-23T22:24:22.840