multiple desktops and the windows api

In a previous post about the Macbook Pro, I mentioned that one of the things I love about OS X is the multiple desktop feature. I also mentioned that Windows 10 had just come out and it promised to have similar functionality. So, about that..

Windows 10 does indeed have support for multiple desktops and what’s more, it’s pretty damn good. There are some differences between the Windows and Mac when it comes to multiple desktops but overall they both work just as well. The one major thing that Windows lacks is the ability to switch to specific desktops easily using the keyboard. On the Macbook, I can set keyboard shortcuts in the system preferences to accomplish this. Windows has no such thing out of the box. I am a geek obsessed with productivity and so this was really annoying.

When I started using Windows 10, I found a solution to the problem using open source tools. I found the Windows-10-Virtual-Desktop-Switching-Shortcut project on GitHub that claimed to do exactly what I wanted. I gave it a shot but found that I could not get the keyboard shortcut to work. However, a utility called VirtualDesktopSwitcher, included in the project, did work. I searched some more and came across a popular utility called AutoHotKey that allows you to pretty much do anything in Windows using the keyboard. I hooked the two of them up together and voila, I had my solution!

Unfortunately, after a routine Windows Update last week, VirtualDesktopSwitcher ceased to work. My guess is that the reverse engineered Windows API that allowed VirtualDesktopSwitcher to work in earlier versions of Windows 10 was removed or altered. Sigh. Back to the drawing board.

Luckily, I was able to find an alternative, again on GitHub, called VirtualDesktopAccessor. In addition to switching desktops, it offers much more desktop-related capabilities. The instructions on the readme even show how to set it up using AutoHotKey! In order to compile the code, I had to grab a copy of Visual Studio 2015 Community Edition. To run the utility on a Windows machine without Visual Studio installed, I had to install the 2015 runtimes from Microsoft.

For those of you who don’t know what C++ even is, you can download the 64bit version of VirtualDesktopAccessor.dll that I compiled. Place it in the same directory as your ahk (AutoHotKey) file. For an ahk file sample, see the VirtualDesktopSwitcher page. My only alteration was to add the following for using Windows-{number} to access desktops 1-9: