Create a New Space in Mavericks using Applescript

In Mavericks, is it possible to use Applescript to create a new Space in Mission Control?

I also tried the following code to switch to another Space, but it does not seem to do anything...

tell application "System Events"
    tell process "Finder"
        keystroke "2" using control down --switches to space 2
    end tell
end tell

Solution 1:

delay 0.5 -- time to release command if the script is run with command-R
tell application "System Events"
    key code 126 using control down -- control-up
    delay 1
    do shell script "MouseTools -x 1900 -y 60;sleep 1;MouseTools -leftClickNoRelease;MouseTools -releaseMouse"
    key code 53 -- escape
end tell

You can download MouseTools from http://www.hamsoftengineering.com/codeSharing/MouseTools/MouseTools.html. See http://osxnotes.net/applescript.html for a list of key codes.

Solution 2:

Use key code instead of keystroke. I don't see why MouseTools is needed. Assuming you have cntrl-2 bound to space to, this should switch you (at least in Yosemite):

tell application "System Events"
    key code 19 using control down
end tell

-- numkey code
-- 1 18
-- 2 19
-- 3 20
-- 4 21