Automator + Applescript how to: new Desktop (open Calendar and Reminders in it)
Took a while but I came up with this. Works on Mavericks.
on run {input, parameters}
my openNewSpace()
my launchApplication("Reminders")
my launchApplication("Calendar")
end run
on openNewSpace()
tell application "System Events"
--mission control starten
do shell script "/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control"
tell process "Dock"
set countSpaces to count buttons of list 1 of group 1
--new space
click button 1 of group 1
--switch to new space
repeat until (count buttons of list 1 of group 1) = (countSpaces + 1)
end repeat
click button (countSpaces + 1) of list 1 of group 1
end tell
end tell
end openNewSpace
on launchApplication(app_name)
tell application app_name
launch
end tell
end launchApplication
Works fine on macOS Mojave (10.14.3)
AppleScript:
tell application "System Events"
tell application "Mission Control" to launch
tell group 2 of group 1 of group 1 of process "Dock"
click (every button whose value of attribute "AXDescription" is "add desktop")
tell list 1
set countSpaces to count of buttons
delay 0.5
click button (countSpaces)
end tell
end tell
delay 0.5
tell application "Calendar" to launch
tell application "Reminders" to launch
end tell
JXA:
Application("Mission Control").launch()
var proc = Application("System Events").processes['Dock']
var group = proc.groups[0].groups[0].groups[1]
var bs = group.buttons.whose({ description: "add desktop"})
Application("System Events").click(bs[0])
delay(0.5)
var li = group.lists[0]
Application("System Events").click(li.buttons[li.buttons.length - 1])
delay(0.5)
Application("Calendar").activate()
Application("Reminders").activate()