1

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
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.

1

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

You must log in to answer this question.

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