Windows 10: Change shortcut keys to switch between desktops

60,319

Solution 1

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.

Solution 2

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}

Solution 3

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
Share:
60,319
Faisal Khurshid
Author by

Faisal Khurshid

Updated on September 18, 2022

Comments

  • Faisal Khurshid
    Faisal Khurshid over 1 year

    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?

    • Yibo Yang
      Yibo Yang almost 8 years
      Here's a gist for those who are used to Unity's Ctrl + Alt + Left/Right
  • Ciantic
    Ciantic over 8 years
    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.
  • valkirilov
    valkirilov about 8 years
    Is there a native solution?
  • NateR
    NateR about 8 years
    @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.
  • valkirilov
    valkirilov about 8 years
    @ElectroPulse I tried your method but when I assign ^!Right (Ctrl + Alt + Arrow) it is not working, do you have any ideas why?
  • NateR
    NateR about 8 years
    @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.
  • ACK_stoverflow
    ACK_stoverflow almost 8 years
    Thank you! Microsoft takes one of the best features from Linux desktops and doesn't even map the keypresses properly? This will save me!
  • Mehrdad
    Mehrdad over 6 years
    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.
  • Wolfpack'08
    Wolfpack'08 over 6 years
    I like this one better becasue !^ is more efficient than ^. CTRL+Arrow is very important and reserved. But CTRL+Win+Arrow is not reserved.
  • user57368
    user57368 about 4 years
    Is there any way to set double arrow left or right to set instead of ^Right