在AppleScript中,如何设置一个应用程序在另一个退出后退出?

时间:2015-01-19 22:30:14

标签: macos applescript

我有一个AppleScript应用程序,每60秒自动保存一次进度。我正在编写一个AppleScript应用程序,在其中打开一个特定的文档,将该文档窗口的索引号设置为1并打开我的自动保存应用程序。

当我按下Command + Q退出Pages时,我想让自动保存应用退出。

出于安全考虑,我省略了部分文件路径,但这是我的代码: tell application "Pages" to open "/Users/Documents/Home//Automator Article.pages/" tell application "Pages" to set index of window "Automator Article.pages" to 1 tell application "Pages autosave" to launch

1 个答案:

答案 0 :(得分:0)

您不能触发Applescript按⌘Q退出Pages。这不可能。 一种解决方案是触发退出Pages的脚本,然后触发“Pages autosave”applet(而不是按⌘Q退出Pages)。

tell app "Pages" to quit
tell app "Pages autosave" to quit

例如,您可以从Pages的脚本菜单中触发该脚本。 另一种选择是在“页面自动保存”小程序中添加一个菜单,该小程序依次退出页面及其自身。