我一直在用Applescript做一些东西,给我的一个朋友,通常,通过一些搜索/研究,我能够克服我一直面临的问题。然而..。我发现了一个我不理解的问题。
例如,我有:
tell application "Acrobat Distiller"
Distill sourcePath inputFile1 adobePDFSettingsPath fullPathToJobOptions
end tell如果我将其替换为:
tell application "/Applications/Adobe Acrobat XI Pro/Acrobat Distiller.app"
Distill sourcePath inputFile1 adobePDFSettingsPath fullPathToJobOptions
end tell我没有任何问题..。但是..。如果我这样做:
set thePathToDistiller to "/Applications/Adobe Acrobat XI Pro/Acrobat Distiller.app"
tell application thePathToDistiller
Distill sourcePath inputFile1 adobePDFSettingsPath fullPathToJobOptions
end tell我在"Distill inputFile1 adobePDFSettingsPath fullPathToJobOptions“这一行得到一个错误。更确切地说是"sourcePath“这个词。错误是:“语法错误:预期的行尾,但找到标识符”
这里可能存在的问题是什么?(感谢您的帮助!) :)
发布于 2014-12-27 10:47:55
在……里面
tell application "Acrobat Distiller"编译器可以看到程序的名称,并在编译时加载程序的字典。有了字典,它就知道Distill是什么意思以及它的参数是什么。
同上
tell application "/Applications/Adobe Acrobat XI Pro/Acrobat Distiller.app"程序的名称(实际上是路径)就在那里的引号中,编译器可以查看应用程序来提取其字典。
在……里面
tell application thePathToDistiller编译器不知道您正在与哪个程序交互。只有在运行时,脚本才知道存储在thePathToDistiller中的值,而让编译器知道要查找哪个应用程序的字典已经太晚了。
发布于 2014-12-27 10:59:04
你可以用"using terms from...“来包装它。块,如下所示:
set thePathToDistiller to "/Applications/Adobe Acrobat XI Pro/Acrobat Distiller.app"
using terms from application "Acrobat Distiller"
tell application thePathToDistiller
Distill sourcePath inputFile1 adobePDFSettingsPath fullPathToJobOptions
end tell
end using terms from添加:
我刚刚用iTunes测试了一下;
set thePathToDistiller to "/Applications/iTunes.app"
using terms from application "iTunes"
tell application thePathToDistiller
playpause
end tell
end using terms from这是可行的。
https://stackoverflow.com/questions/27663893
复制相似问题