Switching Windows 10 Virtual Desktops using Swipe Gestures

I recently switched to Windows 10 to use the new Windows Subsystem for Linux. After switching, I’ve found Windows 10’s built in Virtual Desktops to be very useful. Previously, I’ve used VirtuaWin for virtual desktops on Windows, so having it built-in is very nice.

However, the other GUI OSes I use, OS X and Ubuntu, both support swipe gestures to switch between desktops or workspaces. Therefore, I wanted to add swipe gestures for switching between virtual desktops on Windows 10.

Touchpad brands

I have a touchpad by Synaptics, which is (one of?) the largest laptop touchpad producers. The script below has been tested only on my Synaptics touchpad. It should work on most Synaptics touchpads, as long as you have the latest driver. Someone figured out how to enable swiping to switch virtual desktops on ElanTech touchpads and posted it on Reddit. If you have a touchpad from a different company such as Alps or Cirque, you can try modifying my script.

AutoHotkey

I’m using AutoHotkey to add the swipe gestures. AutoHotkey allows you to map your computer’s inputs to other inputs. For example, when you press a certain key, AutoHotkey can make your programs think you pressed a different key.

Synaptics implements gestures as a mapping from touchpad inputs to Windows keyboard shortcuts. For example, using 3 fingers to swipe left or right triggers the keyboard shortcut for switching between active windows (Ctrl + Alt + Tab + Enter and Ctrl + Alt + Tab + Shift + Enter). We can use AutoHotkey to capture these inputs and transform them into the inputs that switches the virtual desktops.

The script

Here’s the AutoHotkey script to transform Synaptics 3-figure swipe gestures into keyboard shortcuts to switch between virtual desktops:


swipeDirection := ""

^!Tab::
	swipeDirection := "L"
return

^!+Tab::
	swipeDirection := "R"
return

$Enter::
	if (not swipeDirection) {
		SendInput {Enter}
	} else if (swipeDirection = "L") {
		SendInput ^#{Left}
	} else if (swipeDirection = "R") {
		SendInput ^#{Right}
	}
	swipeDirection := ""
return

Disclaimer: I’m by no means an AutoHotkey expert. If you know a way to improve this script, please let me know in the comments!

It took me a while to come up with this script because the Enter key is pressed after the Ctrl, Alt, and Tab keys are released. Depending on how long you swipe for, the delay between pressing ^!Tab and Enter is variable. By adding a swipeDirection variable to maintain state, it doesn’t matter how long it takes to swipe.

4 thoughts on “Switching Windows 10 Virtual Desktops using Swipe Gestures”

  1. Hey I just tried your script on my Dell Vostro 3558, it works for 3 finger scrolling but I want to modify it for 4 finger scrolling, how do I do that. Also I only recently started making AutoHotKey scripts so I am a bit new to it, could you please explain what these lines in your code mean. swipeDirection := “” (is this some sort of a variable) and $Enter:: ?

    1. I’m still working through this it on my Lenovo Y700 (which has an ELAN touchpad). It seems like this script “should” be somewhat touchpad-independent. It sounds like Synaptic touchpads default to “Ctrl+Alt+Tab” vs my touchpad sends “Alt+Tab” by default, so I removed the ‘^’ at the beginning of the Tab lines which now allows it to capture the input. It doesn’t like sending the Switch Desktop command though. I’ll post back when/if I can get it working.

  2. I’m smart…let’s try again without replying to another comment….

    Here’s what I needed to do to get it working (thanks to Youtube for this…https://www.youtube.com/watch?v=vPG4WCx9zJU). I have a Lenovo Y700 touchpad with an ELAN touchpad. Unfortunately the registry file you download from the link replaces all of your settings, so I wouldn’t recommend using it. I don’t think you need the “ThreeFinger” keys, but I included them just in case. This uses four fingers which I’m not super thrilled. If I can get it to work with three keys, I’ll post back.

    Registry Key:
    [HKEY_CURRENT_USER\SOFTWARE\Elantech\SmartPad]
    “ThreeFingerMove_Enable”=dword:00000001
    “ThreeFingerMoveLeft_Enable”=dword:00000001
    “ThreeFingerMoveLeft_Func”=dword:00000a04
    “ThreeFingerMoveLeft_Mode”=dword:00000000
    “ThreeFingerMoveRight_Enable”=dword:00000001
    “ThreeFingerMoveRight_Func”=dword:00000a05
    “ThreeFingerMoveRight_Mode”=dword:00000000
    “ThreeFingerMove_UD_ShowItem”=dword:00000001
    “ThreeFingerMove_LR_ShowItem”=dword:00000001
    “FourFingerMove_Enable_Mode”=dword:00000000
    “FourFingerMove_Enable”=dword:00000001
    “FourFingerMoveUp_Enable”=dword:00000000
    “FourFingerMoveUp_Func”=dword:00000013
    “FourFingerMoveDown_Enable”=dword:00000000
    “FourFingerMoveDown_Func”=dword:00000007
    “FourFingerMoveLeft_Enable”=dword:00000001
    “FourFingerMoveLeft_Func”=dword:00000003
    “FourFingerMoveRight_Enable”=dword:00000001
    “FourFingerMoveRight_Func”=dword:00000004
    “FourFingerMove_UD_ShowItem”=dword:00000001
    “FourFingerMove_LR_ShowItem”=dword:00000001

    Script:
    Browser_Back::SendInput {LCtrl down}{LWin down}{Right}{LCtrl up}{LWin up}
    Browser_Forward::SendInput {LCtrl down}{LWin down}{Left}{LCtrl up}{LWin up}

Leave a Reply

Your email address will not be published. Required fields are marked *