Move window between desktops?

I would like to create a shortcut that when pressed, moves the current window to another desktop. Is there an action for this?

eg. from desktop 3 to desktop 2.
image

If you click and hold in the title bar of a window in Desktop 1 (say) and press Control-4 (say), it will move the window to Desktop 4. I'm not sure an action would improve on that built-in shortcut.

1 Like

Adding to @mrpasini's response - The Mission Control Desktop shortcuts are under System Preferences - Keyboard - Shortcuts. You can modify them there if you wish.

KC

2 Likes

Perhaps I was unclear. I was hoping to create a shortcut that move the current window between desktops (like to move the current chrome window to desktop 2), not to switch between them.

1 Like

Gotcha. I was piggybacking on @mrpasini's response. As far from your OP, there were a few past posts that discuss this, in the past, but I think it was determined that there was no Apple issued API that KM could tap into. I remember @ccstone attempted an Apple Script in the past but I don't know how that worked out.

What I do, as mitigation, is have certain apps open in certain desktops by clicking the dock icon - Options and selecting the desktop that I want.

Other than that, maybe the scripting gurus have developed solution. I remember when researching this, a while ago, that there was an app called SizeUp. There is a trial version. Try that if the scripters are unable to chime in or find an adequate solution.

KC

1 Like

I think I have a solution for you.

Make sure you've enabled the keyboard shortcuts the way kcwhat has already described.

Then create as many macros like this one as you have different Spaces (you've called them desktops)

You need to change the bits highlighted in red to suit you as follows:

  1. Use the same hotkey trigger for each one so you get a conflict palette allowing you to choose desktop 1, desktop 2, etc. In my version, I use control-option-shift-command-P as the trigger.

  2. Name each of the macros the same except for the digit: 1, 2, 3, etc so when the conflict palette is show you then just have to press the digit key to make the switch.

  3. In each macro, change the keystroke typed appropriately: for example ^1 for desktop 1, ^2 for desktop 2, etc. Obviously these should match the setting you made in System Preferences as described by kcwhat.

That's it. It works here for me provided the window of the app I want to move to a different space is at the front and activated.

Hope this helps.

Extra: I've just been playing with this and noticed some odd behaviour. Like, the first time you use this the app gets moved to the desired space but you're left sitting in the space you've just moved it from. Also, some apps seem not to like having this done to them: for example, iTerm just quits. So, this may not be a total solution, but is probably best considered as a starting point! Good luck!

Addendum: I now know what the problem is: change the value "15" in the mouse click action to "70". The macro was accidentally closing the app by clicking on the red button.

4 Likes

@tiffle to the rescue!

Nope! Keyboard Maestro to the rescue!! Thanks.

I forgot to mention that BetterTouchTool does this as an action.

1 Like

What's the click left button for (15 to the right and 5 down)?

That's my guess...

Hi, @bocciaman. On this topic, you might want to check out: Desktop Spaces • Macros to Improve Navigation and Window Management

1 Like

I have this '1 functionality' setup with BetterTouchTool (BTT). It was much easier to set up in BTT because BTT had an action for moving the frontmost app one space to the right or left of the current one using hotkeys.

Without going into lots of details about the implementation of my desktop workspace switching system (many aspects of which have been discussed elsewhere in this forum) here's the Move a Window part of my system:

I have a macro for switching desktops that pops up a menu of 30+ desktop names. The list is in order of most recently used. I can pick from the list by typing a single letter that identifies the entry or by moing and clicking the mouse. Normally the list is titled "Pick a DeskSpace to Go To:". However, if I am moving a window along with the desktop workspace switch, the title reads "Moving Window To:"

How does the macro know if I am wanting to move a window along with the desktop workspace switch? In that macro is a test for whether or not the left mouse button is down when the macro is invoked. If the mouse button is down, I presume that it's being held down in the title bar of the window that I want to move.

If I hold the mouse down when I trigger the macro, the macro remembers the mouse state and position. So when the menu pops up, I no longer have to hold the mouse button down, I can pick from the list of names using the mouse. Before the macro actually initiates the desktop workspace switch, it moves the mouse to the remembered position and holds the left button down, then it initiates the switch, pauses slightly, and releases the mouse button.

If you only have a handful of desktop workspaces, then the method above, described by @mrpasini and @kcwhat should work very straightforwardly. But the Mission Control Keyboard Shortcuts are limited to 16 desktops, identified by number. I wanted lots more desktops and to be able to identify them by name, with a name that stayed with the desktop even if I rearranged their order in Mission Control.

I also have hotkeys assigned to many of my desktops so I can bypass the menu. When I type a hotkey, to move a window along with me I have to hold the mouse buton down on the titlebar, as with the standard Mission Control hotkeys. But some of my desktop hotkey take two hands (as do some of the standard Mission Control hotkeys), which makes it hard to hold the mouse button.

What I do to avoid holding the mouse with my elbow is move to the target window first with the two-handed hotkey, then move back with my Previous Desktop hotkey (which can be easily pressed with my left hand: ⌥⌘Space), I grab the window titlebar with the mouse, and press the Previous Desktop hotkey again, which takes the focus and the window to the new desktop.