5
votes

Windows 10 has finally multi desktops, you can switch desktops with ctrl+win+right (or left) keys. It's a nice feature, but you have two use two hands to switch desktops. I'm trying to map the keys like this with autohotkey so I can use just one hand and keep the other one in the mouse..

ctrl + mouse wheel up   --> ctrl + win + right
ctrl + mouse wheel down --> ctrl + win + left

the message box comes up so the ctrl + wheel up is working, but it doesn't switches desktops.

~LControl & WheelUp::
MsgBox, Go to desktop right.
Send, {ctrl up}{lwin ctrl righ}
return

~LControl & WheelDown::
MsgBox, Go to desktop left.
Send, {ctrl up}{lwin ctrl left}
return

Any idea why is this not working?.

3

3 Answers

4
votes

You can easily switch between two virtual desktops in Windows 10 by using Ctrl+Win+ or Ctrl+Win+ shortcuts.

But to make this even simpler and easy to use I’ve made this Autohotkey script to toggle betweeen two virtual desktops by just using the (`) key which is the least used key in keyboard.

`::
if (Toggle := !Toggle)
    Send #^{right}
else
    Send #^{left}
return

Note:- This script works for switching between two desktops only. For creating another virtual desktop you can use the shortcut Ctrl+Win+D.

3
votes

Inside {} only one key should be specified and I think there's no need for passthrough modifier ~:

LCtrl & WheelUp::Send, {LCtrl up}{LWin down}{LCtrl down}{Right}{LWin up}{LCtrl up}
LCtrl & WheelDown::Send, {LCtrl up}{LWin down}{LCtrl down}{Left}{LWin up}{LCtrl up}

Maybe the standard syntax for modifier keys will also work without sending up-event for LCtrl key:

LCtrl & WheelUp::Send, #{Right}
LCtrl & WheelDown::Send, #{Left}
1
votes

I know this is an old question but there is now a much better solution that has official support from Microsoft and is really easy to use. Microsoft has recently released an open source tool called Powertoys https://github.com/microsoft/PowerToys . It includes a keyboard manager with a tool for remapping keyboard shortcuts. Its really simple.