Creating desktops and opening programs on those desktops using applescript 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.
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...



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 &amp; 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.]



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 &amp; launch Chrome.
Then right click it in the Dock &amp; set to This Desktop.
[btw, Apple seem to use the terms Space &amp; Desktop interchangeably. I've never figured out the pattern.]



Now just rinse &amp; 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 &amp; 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



Automatically rearrange Spaces - no no no. This will lose your carefully placed numbering &amp; 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 &amp; 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.