Windows 10: Change shortcut keys to switch between desktops

25

12

In Windows 10, the shortcut keys for switching virtual desktop are ctrl + win + right / left arrow. I'd like to simplify it, by changing it to ctrl + right or left arrow key only. How can I do this?

Faisal Khurshid

Posted 2015-07-31T22:39:20.973

Reputation: 565

Question was closed 2017-04-20T20:46:02.390

1

Here's a gist for those who are used to Unity's Ctrl + Alt + Left/Right

– Yibo Yang – 2016-07-19T01:59:18.830

Answers

20

AutoHotkey is a great program for doing this exact type of thing. It is an very useful program for remapping keyboard keys, letting you set up hotkeys, and automating tasks. Here are the steps to set this up:

  1. Download AutoHotkey (http://www.autohotkey.com/) and install it.
  2. Right-click on your desktop > New > Autohotkey Script (name it whatever you want).
  3. Right-click, Edit Script.
  4. Paste the following text under the already-present text:

#NoTrayIcon ^Right::^#Right ^Left::^#Left

  1. Save and run the script to test its functionality.
  2. If it performs as expected, copy the script into the startup folder* so that it will run every time your computer starts.

Optionally, you can compile the script to run as a standalone .exe that can be run on other computers that don't have AutoHotkey installed. To do this, right-click the script file, and click "Compile Script."

*To access the startup folder in Windows 10, open "Run" (either press Windows Key + R, or search for it in the start menu) and type either (without quotes): "shell:startup" (to run the script for just the current user) or "shell:common startup" (to run it for all users). Paste it in the folder that opens.

NateR

Posted 2015-07-31T22:39:20.973

Reputation: 709

4

If you have boat loads of Virtual Desktops, you might want to change to desktop number X. This is quiet difficult from pure AHK, but I've created a DLL to do just that, it's especially meant for AHK and available in GitHub.

– Ciantic – 2015-10-24T21:09:12.790

1Is there a native solution? – valkirilov – 2016-02-23T17:05:19.450

@valkirilov: Not that I know of.

If anyone else knows of a way, feel free to chime in if you happen to run across this. – NateR – 2016-02-24T05:31:30.193

@ElectroPulse I tried your method but when I assign ^!Right (Ctrl + Alt + Arrow) it is not working, do you have any ideas why? – valkirilov – 2016-02-25T07:53:30.000

@valkirilov Hmm... That's strange. I just reproduced the issue. I am able to use it to open a message box using MsgBox, but am unable to remap ctrl+alt+right to any keypresses. Very strange, no idea why... I don't know the inner workings of Autohotkey well enough to have an answer. – NateR – 2016-03-04T02:21:04.563

Use #NoTrayIcon ^!Right::send {LWin down}{LCtrl down}{Right}{LWin up}{LCtrl up} ^!Left::send {LWin down}{LCtrl down}{Left}{LWin up}{LCtrl up} instead. – Mehrdad – 2017-08-03T14:56:53.790

Is there any way to set double arrow left or right to set instead of ^Right – user57368 – 2020-02-09T11:44:14.287

4

To respond @valkirilov's comment under ElectroPulse's answer, I see this post is helpful. Remapping Ctrl-Alt-Arrow in Windows 10 using AutoHotkey

In short, using

!^Right:: send {LWin down}{LCtrl down}{Right}{LWin up}{LCtrl up}
!^Left:: send {LWin down}{LCtrl down}{Left}{LWin up}{LCtrl up}

HD189733b

Posted 2015-07-31T22:39:20.973

Reputation: 141

Thank you! Microsoft takes one of the best features from Linux desktops and doesn't even map the keypresses properly? This will save me! – ACK_stoverflow – 2016-07-26T18:01:17.140

I like this one better becasue !^ is more efficient than ^. CTRL+Arrow is very important and reserved. But CTRL+Win+Arrow is not reserved. – Wolfpack'08 – 2017-11-09T02:06:07.383

1

I created some shortcuts for switching between desktops. I wanted a 3x3 grid of desktops (virtually, or in my mind-map only--in reality they are linear). I wanted the number pad keys to map to each desktop respectively.

The way the hotkeys work is by

  • assuming there are 9 desktops total
  • scrolling at least 9 to the left/right to ensure we're at a linear edge of known desktops
  • scrolling back the right number to get where I want.

Since there is no easy way to move a window to a specific desktop, I used Win+Numpad0 to bring up the "move to desktop" menu for that window. It's a compromise I have little hope of resolving soon (but I did post my own question about it).

Here are my shortcuts:

; Windows+Number pad keys = Windows 10 desktop switching.
; number pad to match a 3x3 desktop
#Numpad1::
#NumpadEnd::
    Send, {LWin down}{Ctrl down}{Right 9}{Left 2}{Ctrl up}{LWin up}
    return
#Numpad2::
#NumpadDown::
    Send, {LWin down}{Ctrl down}{Right 9}{Left 1}{Ctrl up}{LWin up}
    return
#Numpad3::
#NumpadPgDn::
    Send, {LWin down}{Ctrl down}{Right 9}{Ctrl up}{LWin up}
    return
#Numpad4::
#NumpadLeft::
    Send, {LWin down}{Ctrl down}{Left 9}{Right 3}{Ctrl up}{LWin up}
    return
#Numpad5::
#NumpadClear::
    Send, {LWin down}{Ctrl down}{Left 9}{Right 4}{Ctrl up}{LWin up}
    return
#Numpad6::
#NumpadRight::
    Send, {LWin down}{Ctrl down}{Right 9}{Left 3}{Ctrl up}{LWin up}
    return
#Numpad7::
#NumpadHome::
    Send, {LWin down}{Ctrl down}{Left 9}{Ctrl up}{LWin up}
    return
#Numpad8::
#NumpadUp::
    Send, {LWin down}{Ctrl down}{Left 9}{Right 1}{Ctrl up}{LWin up}
    return
#Numpad9::
#NumpadPgUp::
    Send, {LWin down}{Ctrl down}{Left 9}{Right 2}{Ctrl up}{LWin up}
    return
;   Send, {LWin down}{Tab}{LWin up}
;   Sleep, 3000
;   Send, {Tab 1}{Right 2}
;   Sleep, 3000
;   Send, {Enter}
;   Sleep, 3000
;   return
;
;   Bring up the "move this window to desktop..." menu.  Since the menu is always different, don't operate on it.  Just leave it at that.
#!Numpad0::
#!NumpadIns::
#+Numpad0::
#+NumpadIns::
#Numpad0::
#NumpadIns::
    Send, {LWin down}{Tab}{LWin up}
    Sleep, 400
    Send, {AppsKey}M
return

K Robinson

Posted 2015-07-31T22:39:20.973

Reputation: 897