Automator + Applescript 如何:新桌面(在其中打开日历和提醒) [英] Automator + Applescript how to: new Desktop (open Calendar and Reminders in it)

查看:27
本文介绍了Automator + Applescript 如何:新桌面(在其中打开日历和提醒)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题就是我想要达到的目标.

The title is what I'm trying to achieve.

在 Automator 中,我试图简单地记录打开新桌面的操作,然后打开其中的应用程序 -- 但我得到了

In Automator, I've tried to simply record the actions of opening a new desktop, and then opening the apps in it -- but I get the

Watch Me Do"操作遇到错误.检查操作的属性并再次尝试运行工作流

The action 'Watch Me Do' encountered an error. Check the actionʼs properties and try running the workflow again

此外,如果我这样做,记录的操作是单击桌面 4 按钮".

Furthermore, if I do it in this way, the action that is recorded is "Click the Desktop 4 button".

同样,我在谷歌上搜索并找到了创建特定桌面(例如桌面 3)的 Applescripts,但我总是打开不同数量的桌面.所以我希望工作流简单地制作一个桌面,而不管我已经打开了多少桌面.此外,我找到的许多 Applescripts 都是面向 Mavericks 的,它们仍然有 Spaces,而我有 Yosemite.

Similarly, I googled and found Applescripts that create specific Desktops (e.g. Desktop 3) but I always have a different amount of Desktops open. So I want the Workflow to simply make a new Desktop regardless of the amount I have open already. Moreover, many of the Applescripts I do find are geared towards Mavericks which still had Spaces and I've got Yosemite.

我可以弄清楚如何让脚本打开日历和提醒,所以主要问题是如何打开它或创建一个新的桌面.

I can figure out how to make the script open Calendar and Reminders, so the main issue is how to have it open or create a new Desktop.

推荐答案

花了一段时间,但我想出了这个.适用于小牛队.

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

这篇关于Automator + Applescript 如何:新桌面(在其中打开日历和提醒)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆