![Applescript - 为什么killall不会杀死我的应用程序](https://linux22.com/image/1596567/Applescript%20-%20%E4%B8%BA%E4%BB%80%E4%B9%88killall%E4%B8%8D%E4%BC%9A%E6%9D%80%E6%AD%BB%E6%88%91%E7%9A%84%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F.png)
我的 applescript 的应用程序名称是“myApp”,我只是想知道为什么它在启动 Tableau 后没有终止我的应用程序。
“on run” 工作正常,并且在启动 Tableau 后终止了主机应用程序,但是当我将单击的文件名作为参数传递时,“on open” 的行为并不如预期:
on open fileRef
do shell script "/Applications/Tableau\\ Desktop\\ 2019.1.app/Contents/MacOS/Tableau -DConnectPluginsPath=/Users/myUser/Downloads/connector " & quoted form of POSIX path of fileRef & " killall myApp"
end open
on run
do shell script "/Applications/Tableau\\ Desktop\\ 2019.1.app/Contents/MacOS/Tableau -DConnectPluginsPath=/Users/myUser/Downloads/connector & killall myApp"
end run
谢谢。
答案1
这是一个愚蠢的错误,我没有在“on open”中的“killall myApp”前面加上“&”
正确版本如下:
on open fileRef
do shell script "/Applications/Tableau\\ Desktop\\ 2019.1.app/Contents/MacOS/Tableau -DConnectPluginsPath=/Users/myUser/Downloads/connector " & quoted form of POSIX path of fileRef & " & killall myApp"
end open
on run
do shell script "/Applications/Tableau\\ Desktop\\ 2019.1.app/Contents/MacOS/Tableau -DConnectPluginsPath=/Users/myUser/Downloads/connector & killall myApp"
end run