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}
}
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 pressingWIN + SHIFT + 1
would open a new Chrome window, for example. – Ninjakannon – 2016-12-26T23:42:50.297Update: version (0.9.1) works without any problem on ver. 1903 from may 2019 – Dariusz Filipiak – 2019-05-27T02:33:54.137