106

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.

10 Answers10

46

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
  • 1,343
  • 8
  • 9
20

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
  • 301
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}
}
9

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!

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

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

dblacha
  • 11
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).

Roel
  • 168
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

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
  • 155