I'm new to applescript and I'd like some help with something I'd like to create. I've searched around on the internet and found a few pages, here and here, that describe pretty much what I would like to do, but I don't completely understand it.

I'd like to make an application that closes everything on the computer (not required), opens 4 desktops, first one with google chrome open, third with iMovie open, and fourth with textedit open.

Could anyone help with my coding? I here's what I have so far. I'm not using full code, just dragging launch applications to places in the application

I believe that the only things that I need to add would be code in between the launch applications that opens a new desktop and switches to it(2 times to create the empty space in desktop 2). I'm not entirely sure how to do this though.

  • Welcome to Ask Different! Whilst we can help with specific problems you're facing, it wouldn't be possible to be able to keep up with writing code for everyone! Add some initial code you've tried and some research into potential solutions for initial stages of such a script, and focus your question to a specific issue you're having with that code.
    – grg
    Sep 8, 2018 at 22:07
  • Do you need this to be, in effect a portable solution, once that works on any Mac you take it to? Or is it just so you can have each of those apps on its own Space every time? If it's the 2nd, there's a much simpler way to do it, a one-off solution.
    – Tetsujin
    Sep 9, 2018 at 6:52
  • @Tetsujin The second way would be best. I'm not planning on using this on other computers, just my laptop.
    – Goldeneyes
    Sep 9, 2018 at 14:17
  • Have a look at apple.stackexchange.com/a/179403/85275 & see if it helps - pinning apps to specific Spaces is a real time-saver
    – Tetsujin
    Sep 9, 2018 at 14:27
  • \o/ really glad it helped... Not sure whether to put that in as an answer, or close as a duplicate [because it isn't actually an answer to your question, nor is your question a dupe of the other... so I'm a bit stuck]
    – Tetsujin
    Sep 9, 2018 at 16:06

1 Answer 1


We figured out in comments that although this isn't a solution to the actual problem posted, it did help the OP to achieve the underlying requirement.

First job is to create sufficient Spaces. You can do this in Mission Control, by default Ctrl ⌃ or three-finger swipe up.
Use the + on the right to create the required number - I have 7 here...

enter image description here

Then set up some key commands - long-term these are the best way to get around. This is set in System Prefs > Keyboard > Shortcuts > Mission Control [You can only see as many 'Switch' shortcuts as you have Spaces.]
It will remember which app you last had frontmost when you switch Spaces in this way.

Note - if you have an extended keyboard with a 10-key, by default the Ctrl/num shortcuts are set to the 'qwerty' numbers, not the 10-key numbers & you will have to change the shortcuts manually if you prefer the 10-key.
[The shortcuts are visually identical, but the number keys are recognised as distinct entities in this control panel.]

enter image description here

Then it's a case of populating your Spaces with specific Apps.
If you've never done this before then any app will launch on whichever Space you're on right now; so switch to Space 3 & launch Chrome.
Then right click it in the Dock & set to This Desktop.
[btw, Apple seem to use the terms Space & Desktop interchangeably. I've never figured out the pattern.]

enter image description here

Now just rinse & repeat for each app you want to assign to a given Space, after which you can flit between them all with a simple key command.

Pro Tips
If I ever need, for instance, to add an email attachment from Finder (Space 1) to an email (Space 4) then simply grabbing the header bar of the email & hitting Ctrl ⌃   1 will move that single email to Space 1, where I can drop in the attachment from Finder.

If you ever need an app to 'follow' you around - sometimes I keep Activity Monitor tucked in a convenient corner - then assigning to All Desktops will make it always appear, whichever Space you're in.

Two things to watch out for... Mission Control prefs

enter image description here

Automatically rearrange Spaces - no no no. This will lose your carefully placed numbering & shift things around seemingly at random.

Displays have separate Spaces - If you have more than one physical monitor, then this one is a choice.
Personally, I avoid this one as I like my Spaces to move around in pairs, left & right always the same 'set'. If you want each monitor to be independent, then many people find this a useful way to be able to work in 2 different Spaces simultaneously. To do this you must have more Spaces than monitors.

You must log in to answer this question.

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