问题描述
2部分的问题:
我只是试图运行使用AppleScript从终端程序,所以我尝试:
I'm simply trying to run programs using applescript from the terminal, so I tried:
$ osascript tell application "iTunes" to activate
和得到的错误:
osascript: tell: No such file or directory
给予的完整路径,程序也不能工作。我在想什么?问题的第二部分是我最终想要使用的AppleScript的。我想用它来打开一个应用程序使用我建py2app。可以AppleScript的打开任何Mac应用程序或只是某些那些已经兼容。
Giving the full path to the program did not work either. What am I missing? The second part of the question is what I eventually want to use applescript for. I would like to use it to open an application I built using py2app. Can applescript open any mac app or just certain ones that are already compatible.
感谢
推荐答案
试试这个。注意:您用-e当你正在写的命令。如果没有-E你会给一个路径,一个AppleScript运行。还要注意字符串命令必须用引号括起来。
Try this. Notice you use "-e" when you are writing the command. Without "-e" you would give a path to an applescript to run. Also notice the string command must be in quotes.
osascript -e "tell application \"iTunes\" to activate"
如果你有一个多行的AppleScript你喜欢这个每行...
And if you have a multi-line applescript you use "-e" before each line like this...
osascript -e "tell application \"iTunes\"" -e "activate" -e "end tell"
如果你想打开一个应用程序只使用Unix的打开命令...
If you want to open an application just use the unix "open" command...
open "/path/to/application"
如果你想使用AppleScript打开一个应用程序,并激活命令不起作用(它应该几乎所有的工作,虽然),然后告诉查找程序将其打开。请记住,AppleScript的采用冒号分隔的路径...
If you wanted to open an application using applescript and the "activate" command doesn't work (it should work for almost everything though) then tell the Finder to open it. Remember that applescript uses colon delimited paths...
osascript -e "tell application \"Finder\" to open file \"path:to:application\""
这篇关于与AppleScript的打开的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!