退出终端的Applescript [英] Applescript to quit Terminal

查看:41
本文介绍了退出终端的Applescript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我是 Mac 用户,在 PostScript 中维护一个程序.Postscript 由 Adob​​e Distiller 解释(蒸馏").所以有时我想要第二次或第三次 Adob​​e Distiller 会议.

为了打开这样的实例,我有一个名为DistillerNewInstance.command"的小文本文件:

open -n -a "Acrobat Distiller"osascript -e '告诉应用程序终端"关闭第一个窗口'osascript -e '告诉应用程序终端"退出保存不'

蒸馏器钻头工作得很好.幸福.

但是终端并没有退出.它询问您想终止此窗口中正在运行的进程吗?".上述的一些变体关闭窗口但保持终端运行.拜托,我的 .command 文件中有什么可以让终端悄悄消失?(没有不安全的使用 killall.)

谢谢.

解决方案

考虑执行 open shell 命令直接通过 AppleScript 使用其 do shell script 命令,而不是通过终端应用程序.>

通过使用以下 AppleScript,它将不需要关闭任何终端窗口并退出.

重复3次做shell脚本open -n -a"&空间&Acrobat Distiller"的引用形式结束重复

上面给出的示例将启动 Acrobat Distiller 应用程序的三个实例.

Background: I’m a Mac user, who maintains a program in PostScript. Postscript is interpreted (‘distilled’) by Adobe Distiller. So sometimes I want a second or third session of Adobe Distiller.

To open such an instance I have a small text file named ‘DistillerNewInstance.command’:

open -n -a "Acrobat Distiller"
osascript -e 'tell application "Terminal" to close first window'
osascript -e 'tell application "Terminal" toquit saving no'

The Distiller bit works perfectlly. Happiness.

But Terminal doesn’t quit. It asks "Do you want to terminate running processes in this window?". Some variations of the above close the window but leave Terminal running. Please, what can go in my .command file that will make Terminal quietly go away? (Without unsafe usage of killall.)

Thank you.

解决方案

Consider executing the open shell command directly via AppleScript using its do shell script command instead of via the Terminal application.

By utilizing the following AppleScript it will negate the need to close any Terminal windows and quit it.

repeat 3 times
  do shell script "open -n -a" & space & quoted form of "Acrobat Distiller"
end repeat

The example given above will launch three instances of the Acrobat Distiller application.

这篇关于退出终端的Applescript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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