Spaces, places and faces (and dual monitors)

Is there any chance Keyboard Maestro will be able to move applications around spaces in the future? It drives me nuts that I can’t keep everything in the same place when I disconnect my monitor. I’m basically looking for saved states; I’ve tried every application under the sun:

Size Up, Moom, Stay, Automator, Display Maid, Total Spaces, Optimal Layout and loads of others I can’t remember.

I just want to be able to punch in a hot-key and get my desktops and spaces how I like them.

Any ideas? Does Yosemite allow this?

1 Like

As far as I am aware, Apple has not provided any API for controlling Spaces (including in Yosemite) which severely limits what Keyboard Maestro can do in this are.

Other than trying to UI control Spaces (which does work to a limited degree), there is not much I can suggest. If Apple ever implement a Spaces API I can use, I am sure I will be very quick to add some Spaces actions to Keyboard Maestro.

Thanks for the quick reply Peter.
I can’t believe that they aren’t providing an API for this in Yosemite.

Is it possible that that non-app-store version of KM could use the undocumented API?

It’s a source of constant frustration to me

TotalSpaces and TotalSpaces2 have an API that allows to control Spaces to some extent. I don’t know how they came up with it, but I use it to move windows across spaces and that kind of stuff from KM.

It’s documented here: http://binaryage.github.io/totalspaces-api/ruby/rdoc/TotalSpaces.html

Yeah. I tried total spaces 2 but it wouldn’t create the spaces for me.
I want something that takes whatever configuration I’ve got and changes it to the configuration I want. If that involves quitting apps, reopening other ones, deleting spaces etc then so be it.

When you want to use Final Cut Pro you have different saved layouts that you use for different things. OS X should be no different. It’s frustrating to me to constantly be searching around for this or that app because it’s moved when I disconnected my display etc.

It might be possible, but it wont be Keyboard Maestro. Keyboard Maestro will not be using undocumented APIs.

If undocumented or private APIs will allow it, then perhaps someone can write an AppleScriptable tool that can be controlled from Keyboard Maestro, but its not something I would add to Keyboard Maestro (which is why Keyboard Maestro 2 still runs under Yosemite for example).

As my obsessive desire continues, I am still trying to find a better way to move a window to a particular space on a particular monitor. I have macros that first switch to a space before trying to open up a file but often the app was opened in a different space and the focus of the macro starts jumping around to different spaces and possibly monitors (I have 3).

Because I have setup system level hot keys, such as Control-1 to go to space 1 and Control-2 to go to space 2, I would like to find a way to select a given window, have Keyboard Maestro hold down the mouse button on a given location of that window and hit a control-# to move that window to the space of the #. If I could do this, it does not matter what space the application was originally opened in.

Here is an example, I use FileMaker to develop databases for clients. To quickly open up a FileMaker file you tell Safari in Keyboard Maestro to open a given url, such as: FMP://192.168.1.2/myFMfile.

This first goes to Safari, which could have been originally opened in any space, and then launches FileMaker and tells it to open up the file at that IP address with that file name. FileMaker may have already been opened up in any given space.

I can have Keyboard Maestro bring FileMaker to the front but I can’t predict what space FileMaker opened up the file in.

I have looked into several 3rd party ‘Spaces’ apps as well as AppleScript. I have not found anything very clean or simple in any of them so I keep resorting to find a solution with Keyboard Maestro. Anyone have an idea on how to move a window (front or by name) to a given space on a given monitor, knowing I have hot keys to select the space number (Control-#)? By this I mean I can manually move a window by clicking (click and hold) on the top of a window and hitting a control-# for the space I want to move the window to.

Stephen if you ever figured this out I would love to hear about it! :smiley:

You would think, with El Capitan, there would be some APIs for this sort of
thing. No?

No idea, I have not seriously looked at Captain yet, and don't really intend to in the near future - even if it provides some services, unless they are in Yosemite I wont be able to use them yet.

But if someone finds some APIs for Spaces in any version of OS X, please email me with the details.

Hi James,

SizeUp app I think does what you want. It is the only app I have found that allows me to move a window to another space with the keyboard.

I was in contact with the developer and I think what he does is try to simulate the click over window and the press ctrl and the cursor to move the window to another space. In fact I tried to do that before SizeUp implemented that feature but was not possible at that moment with the then current version of KM. Maybe it’s possible now with KM 7.

Version 7 adds press and hold for keys and mouse buttons, so it may be possible.

Is it now possible using KM7 and ElCapitan to move an active window to another space using a hotkey?

As far as I am aware, there is no public API for this. If you can find the source code to TotalSpaces, then I am happy to look at what API it is using - but off hand I would assume it is using some private API.

Tho whatever the TotalSpaces API is, it looks like it may require the SIP to be disabled …

http://totalspaces.binaryage.com/elcapitan

TotalSpaces2 works by changing the way the Dock program handles spaces. OSX does not provide any other way to control spaces, this is the only way the functionality of TotalSpaces2 can be achieved.

Which is why Keyboard Maestro does not support control over spaces.