2

So the end goal of what I am looking to do is this:

When I am at work I use an external monitor with my MBP. I have a consistent set of spaces and apps that I setup everyday. What I would like to do is create an applescript or combination of applescript & automator application that once launched will create the needed number of spaces on each monitor and open then the appropriate apps into each space.

I don't know if this is best accomplished completely in applescript or as I said using a combination of applescript to create the spaces and automator to open the bulk of the applications and browser windows that I use.

  • not an answer, but there's a wealth of Applescript/Spaces routines at macscripter.net/viewtopic.php?id=23453 – Tetsujin Mar 29 '15 at 14:23
  • @Tetsujin, IIRC Those scripts do not work since OS X 10.8. FWIW Spaces and or Mission Control are not really script friendly, it a really hit or miss depending on what one is trying to do. – user3439894 Dec 16 '17 at 14:04
3

To add one Desktop Space to each monitor/display:

do shell script "/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control"
delay 0.5
tell application "System Events" to click (every button whose value of attribute "AXDescription" is "add desktop") of group 1 of process "Dock"
delay 0.5
do shell script "/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control 1"

One can modify the code to add more desktops.

To switch to a particular desktop / fullscreen app in a dual display setting, e.g. Desktop 3:

do shell script "/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control"
delay 0.5
try
    tell application "System Events" to click (first button whose value of attribute "AXDescription" is "exit to Desktop 3") of list 1 of group 1 of process "Dock"
on error
    tell application "System Events" to click (first button whose value of attribute "AXDescription" is "exit to Desktop 3") of list 2 of group 1 of process "Dock"

end try

There are discussions out there about turning an app to fullscreen mode with script.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .