65

The year is 2021. In Windows 11, how can I move the current focused window to the next windows desktop using shortcut keys only?

I know that I can switch desktops using these combinations:

Win+Ctrl+: Switch to the next desktop

Win+Ctrl+: Switch to the previous desktop

Adding the following shortcut keys seem most comfortable to me - and used in Ubuntu:

Win+Ctrl+Shift+: Move current window to the next desktop

Win+Ctrl+Shift+: Move current window to the previous desktop

Similar shortcut keys to above would be acceptable... but even better if I can re-map them to my preferred combination.

Is there anything like this out of the box? Or do I need to install some 3rd party tools?

Adamski
  • 798

11 Answers11

37

As I haven't used AutoHotkey before, I needed to figure out a few additional steps (compared to what is explained in the existing answers) to find a working solution:

  1. Download and install AutoHotKey
  2. Clone the VD.ahk repository (it is an AutoHotkey library adding several script functions for managing virtual desktops)
  3. Inside the cloned directory, create a new file (arbitrary name, ending with .ahk) and paste the content from @Lorenzo Morelli's answer into it.
  4. Double-click the script to run it. The shortcuts (Win+Ctrl+Shift+: Move current window to the next desktop; Win+Ctrl+Shift+: Move current window to the previous desktop) should now work.
  5. To make sure the script runs on every Windows startup, create a shortcut to it and put it into the folder for your Startup programs. Open that folder by typing shell:startup in the window that pops up after you hit Win + R.
Sejmou
  • 521
28

Win+Ctrl+Shift+: Move current window to the next desktop

Win+Ctrl+Shift+: Move current window to the previous desktop

This ahk script works for me:

^#+Left::
n := VD.getCurrentDesktopNum()
if n = 1
{
    Return
}
n -= 1
VD.MoveWindowToDesktopNum("A",n), VD.goToDesktopNum(n)
Return

^#+Right:: n := VD.getCurrentDesktopNum() if n = % VD.getCount() { Return } n += 1 VD.MoveWindowToDesktopNum("A",n), VD.goToDesktopNum(n) Return

You can find more at https://github.com/FuPeiJiang/VD.ahk and https://www.autohotkey.com/

void
  • 404
23

I put the full AutoHotKey script taken from the @void's answer for helping unexpert/lazy people :)

;#SETUP START
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance force
ListLines Off
SetBatchLines -1
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#KeyHistory 0
#WinActivateForce

Process, Priority,, H

SetWinDelay -1 SetControlDelay -1

;include the library #Include VD.ahk ; VD.init() ;COMMENT OUT static dummyStatic1 := VD.init() if you don't want to init at start of script

;you should WinHide invisible programs that have a window. WinHide, % "Malwarebytes Tray Application" ;#SETUP END

VD.createUntil(3) ;create until we have at least 3 VD

return

^#+Left:: n := VD.getCurrentDesktopNum() if n = 1 { Return } n -= 1 VD.MoveWindowToDesktopNum("A",n), VD.goToDesktopNum(n) Return

^#+Right:: n := VD.getCurrentDesktopNum() if n = % VD.getCount() { Return } n += 1 VD.MoveWindowToDesktopNum("A",n), VD.goToDesktopNum(n) Return

8

No sure which version is being discussed in this thread, but as of this date (2022/07/22), it is easy to move windows among Win-11 virtual desktops.

  1. select the VD icon on the Task Bar, an active desktops bar appears at the bottom of the current display.
  2. hover your mouse over it, then over the source desktop, then up into the space above it showing all its active applications
  3. right click on the application you want to move and then on 'Move To'; select the destination virtual desktop.

There is an additional handy and related feature available if you are working in one virtual desktop and the application you want is already open on a different virtual desktop:

  1. go to the Task Bar and double click on the seemingly unopened app icon. You will instantly be taken to the appropriate virtual desktop and the application.
Peter
  • 121
7

Solution using (the new) AutoHotKey version 2.x

(as version 1.x is now deprecated)

This will allow you to use:

Win+Ctrl+Shift+: Move current window to the next desktop

Win+Ctrl+Shift+: Move current window to the previous desktop

And when you reach the first/last desktop, it will wrap around to the last/first desktop, respectively.

  1. Download and install AutoHotKey v2

  2. Download the VD.ah2 library file (right-click, "Save link as" to download the raw script file)

  3. Save the following code to a script file, eg. myscript.ahk:

    #Requires AutoHotkey v2.0
    #SingleInstance force
    ListLines 0
    SendMode "Input"
    SetWorkingDir A_ScriptDir
    KeyHistory 0
    #WinActivateForce
    ProcessSetPriority "H"
    SetWinDelay -1
    SetControlDelay -1
    #Include %A_LineFile%\..\VD.ah2
    

    ; wrapping / cycle back to first desktop when at the last ^#left::VD.goToRelativeDesktopNum(-1) ^#right::VD.goToRelativeDesktopNum(+1)

    ; move window to left and follow it +^#left::VD.MoveWindowToRelativeDesktopNum("A", -1).follow() ; move window to right and follow it +^#right::VD.MoveWindowToRelativeDesktopNum("A", 1).follow()

    The first block of code is optimization as recommended by the VD script author and loads the VD library.

  4. Place both files in the same folder and …

    • double-click myscript.ahk to run your script;
    • put a shortcut to it in your Startup folder (Win+X, Run, shell:startup) to always start it with Windows.

Bonus: There are more examples available in the VD GitHub repo, in the branch for AHK version 2.

stuckj
  • 133
Tanuki
  • 93
5
  1. Switch to the virtual desktop where is the window that you want to move.
  2. Press Win+Tab and continue holding the Win key.
  3. Drag and drop the window to the wanted virtual desktop at the bottom of the screen.
5

Not with shortcuts, but it is possible with just the keyboard:

  1. Press Win + Tab to open the Task View.
  2. Pess Shift + F10 to open the context menu for the highlighted window.
  3. Use the arrow keys to navigate to the "Move to" option and press Enter. Select the desired desktop using the arrow keys and press Enter again.
1

I haven't found a way to do this myself nor have I found any information online to do this either. It would be nice, but there is sort of a work around for this. If you go to settings-->system-->multitasking, you can set a few desktop settings that enables you to see all of your apps across your desktops from alt-tab and/or on the taskbar.

I personally left alt-tab desktop specific (since I find it to be too cluttered otherwise) but I like to be able to switch to personal chat or whatever without having to desktop over, then go to the window.

1

Simply install FreeVD from github repease. you can setup custom shortcut for doing various kind of movement function

Repo(Upto Win 10): https://github.com/Marcus-L/FreeVD

For windows 11 use this forked version:

Repo(win 11): https://github.com/hisbvdis/freevd-win-11/tree/master

Shortcut menu

M Bala
  • 19
-1

The AHK instructions from @void, @Lorenzo Morelli, and @Sejmou are great. bouncing windows between virtual desktops is now a breeze.

One thing I would like to add if you are having trouble: when Windows Explorer crashes, your desktop count/number are both set to zero in the script, breaking the hotkey commands. Restarting the script fixes that.

It's helpful to set hotkeys to give you a message popup informing you of which desktop you are on, to see if that has happened. If you see "0", then you know you have to restart your script.

Benji
  • 1
-1

This isn't true in Windows 11 (or it has been added).

On the menu bar, click the task-view button (to the right of the search). If not there, right-click task bar, go to settings and enable it.

Click that. It will show all windows and desktops. You can drag the window to the desktop of choice.

EDIT: Noticed that this was answered above using the ⊞ Win+Tab combo to bring up task-view.

Jackdaw
  • 1,834