简体   繁体   中英

How can I change the keys to change desktop in windows 10 with autohotkey?

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

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}

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM