Move Frontmost Window to a Different Space



If this topic title sounds familiar to anyone: yes there has been a similar topic about two years ago, and I’ve posted the ancestor of this macro there.

I’m still using the macro daily, and with the time it has improved and gained functionality.

So here the current version.


The macro allows to move the frontmost window of (almost) any app…

  • one or more Spaces right or left
  • to a specific Space

…by using only the keyboard.


Default configuration of the macro:

Shortcut Result
1 Move window to Space 1
2 Move window to Space 2
3 Move window to Space 3
4 Move window to Space 4
Move window right (one or more Spaces)
Move window left (one or more Spaces)

  • If you press one of the Arrow shortcuts, then the window will move one Space each time.
  • If you hold down one of the Arrow shortcuts, then the window will quickly move through the Spaces until it reaches the last one.

How it works

The macro moves the mouse to the toolbar of the window, performs a click-and-hold, and activates one of Mission Control’s Space movement shortcuts (see below). After that, it moves the mouse back to the previous position.


  • The macro relies on Mission Control’s standard shortcuts for moving between Spaces (at least I think these are the standard settings):


    • If you have modified these shortcuts then you have to adapt the macro.
  • Depending on your computer it might be necessary to adjust the length of the pause (third to last action).


  • BetterTouchTool offers similar functionality.
  • SizeUp (untested)
  • macOS: Open Mission Control and drag a window to one of the Spaces/Desktops at the top.
  • macOS: Click and hold the toolbar of a window and at the same time press one of Mission Control’s Space shortcuts. (That’s what the macro is doing for you.)

Move Frontmost Window to a Different Space.kmmacros (10.6 KB)

Move windows between spaces not working anymore
Move windows between spaces not working anymore

Again a great macro :wink:
Thanks for creating and sharing :+1:


Indeed, as mentioned in another thread, currently the Arrow Key part odf the macro is not working. Probably since Mojave (though I thought it was still working shortly after installing Mojave, but my memory may fool me :thinking: ).

Anyway, something with the handling of the Arrow keys seems to have changed. I’m trying to find a solution. If anybody (maybe @peternlewis?) has an idea, please don’t hesitate to post.


Hallo @Tom, thank you so much in advance. Since I always use your macro in connection with the numbers (⌥ ⌃+1 etc.), I had not noticed that yet.
Unfortunately, Mojave has its quirks, as the unreliable functioning of the F-keys shows.


Honestly, I don’t know what’s going on.

I removed the Arrows and any modifiers from the directional trigger keys (e.g. Move Window to one Space Left: F3), and replaced the directional Mission Control movement shortcuts in System Preferences by something without Arrows (e.g. Move left a space ⌃⌥⌘F5), and it still doesn’t work,

When I do it manually, that is, mouse-click-holding a window, then typing the MC movement key as in System Preferences, then it works.

So, ATM, to me it seems that the Hold Mouse Button action is somehow incompatible with that Mission Control movement (or gets cancelled by it), no matter which trigger keys or which Mission Control shortcuts are used.

Somehow astonishing that the non-directional commands (⌃⌥1 etc.) still work.


Then I propose, for the time being, that you remove the unneeded (and dysfunctional) triggers from the macro, and ideally also the dysfunctional actions.

Unfortunatly I mostly used the ⌃⌥⇢ and ⌃⌥⇠ functions :frowning:
(It was sooo convenient to move a window one Space right with ⌃⌥⇢, then just releasing the ⌥ key, while keeping the other finger on ⌃, and tapping ⇠ (to go back to the previous Space), select the next window, rinse and repeat…)


Thank you for the feedback @Tom :+1:
I'll leave it as it is, because I have not given up hope that Apple will improve/correct this in one of the upcoming updates here.


In Mojave, if you have (in the system or another application) a hot key that is not a modifier-letter combination (specifically that is modifier-arrow, or modifier-function key), and if you use the Type a Keystroke action to simulate that key, the key will not trigger the system/application function.

So since you changed from an arrow to F3, it still does not work.

Change the system hot key to ⌘⌥⇧⌃Q & W (or whatever letters you want).
Make a Keyboard Maestro macro for hot key ⌃⌥⇢ to type a keystroke ⌘⌥⇧⌃W, and use that same type a keystroke anywhere else if you want to change spaces from Keyboard Maestro.


Then just disable the dysfunctional actions, but remove the unneeded triggers. You never know how a macro will interfere with other things when the environment changes, and in that case the less triggers (and actions) the macro has, the better.

And “environment changes” also includes future macros (or Automator workflows, AppleScripts) you will write, or add.


I've already blocked it.Thank you very much for the explanation.
Thank you again for the great macro. Use it every day and I am grateful that you have shared it.


Hold on, @peternlewis has just given us a potentially great hint… (See his post above).


I just read it. I will implement it.
Thanks @peternlewis for the tip :clap:


OK, thanks, @peternlewis ; this works, with some additional complications. But it works :slight_smile:

Will post the the new macro in a couple of minutes.


OK, here is the new macro:

In the screenshot the new stuff is green, the changed stuff is yellow:


The shortcuts in the yellow marked actions must correspond to the shortcuts in your System Preferences for Mission Control Moving left/right a space:


You can choose whatever you want, as long as it consists of modifiers & letters (no F-keys, no arrows).

Here the macro. Just tested brievly, so it may contain bugs / room for improvement:

Move Frontmost Window to a Different Space [ver2.0].kmmacros (12.1 KB)

You have seen that there are two new hotkey triggers:

  • ⌃Left Arrow
  • ⌃Right arrow

They simply have the purpose to “pass through” the Space change (without windows movement). You could also say they reestablish the “old” arrow MC shortcuts, which had to be replaced by clunky non-arrow shortcuts in order to make them work with the macro.

The new condition (the second action, green in the screenshot) has the purpose to filter window movements against mere Space changes (with ⌥-key: window movement to the next Space; without ⌥-key: just switch to the next Space, without dragging along the window).
Technically: Without ⌥-key the mouse is not clicked-and-hold while performing the Space switch.

The direct Space change actions (⌃⌥1 etc.) should be unaffected by all this, and you don’t have to change those shortcuts in the System Prefs (as long as they are ⌃1, ⌃2, etc., of course)


Thanks again, @peternlewis !


Thank you very much for updating your macro :clap::+1:
I kept the previous version (disable). Maybe Apple still has pity and fixes the bug in the next macOS update.


Not sure if this, from Apple’s point of view, is a bug. May well be that it (the interdiction to script system shortcuts that contain other things than letters/numbers) is a security feature (from Apple’s point of view, again) :star_struck: :nauseated_face: :sweat:


Something indeed seems to be buggy here:

All of a sudden my Mission Control shortcut for “Move left a space” stopped working, independently of the KM macro (KM engine off). The shortcut for “Move right” continued working.

Of course I tried it with different shortcut combos in the Keyboard Preferences, I shuffled the Spaces, I unplugged the external display, rebooted the Mac, did an SMC reset, an NVRAM reset.

What finally helped was a reboot in Safe Mode. But, interestingly, while in Safe Mode the Mission Control shortcut was still dysfunctional. Only after booting again in normal mode the shortcut was back to work. So, my only explanation is, it was some weird corruption in the system caches (which get cleared by the Safe Mode).