首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Applescript -需要行尾,但找到了标识符

Applescript -需要行尾,但找到了标识符
EN

Stack Overflow用户
提问于 2014-12-27 10:37:16
回答 2查看 5.5K关注 0票数 1

我一直在用Applescript做一些东西,给我的一个朋友,通常,通过一些搜索/研究,我能够克服我一直面临的问题。然而..。我发现了一个我不理解的问题。

例如,我有:

代码语言:javascript
复制
tell application "Acrobat Distiller"
    Distill sourcePath inputFile1 adobePDFSettingsPath fullPathToJobOptions
end tell

如果我将其替换为:

代码语言:javascript
复制
tell application "/Applications/Adobe Acrobat XI Pro/Acrobat Distiller.app"
    Distill sourcePath inputFile1 adobePDFSettingsPath fullPathToJobOptions
end tell

我没有任何问题..。但是..。如果我这样做:

代码语言:javascript
复制
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“这个词。错误是:“语法错误:预期的行尾,但找到标识符”

这里可能存在的问题是什么?(感谢您的帮助!) :)

EN

回答 2

Stack Overflow用户

发布于 2014-12-27 10:47:55

在……里面

代码语言:javascript
复制
tell application "Acrobat Distiller"

编译器可以看到程序的名称,并在编译时加载程序的字典。有了字典,它就知道Distill是什么意思以及它的参数是什么。

同上

代码语言:javascript
复制
tell application "/Applications/Adobe Acrobat XI Pro/Acrobat Distiller.app"

程序的名称(实际上是路径)就在那里的引号中,编译器可以查看应用程序来提取其字典。

在……里面

代码语言:javascript
复制
tell application thePathToDistiller

编译器不知道您正在与哪个程序交互。只有在运行时,脚本才知道存储在thePathToDistiller中的值,而让编译器知道要查找哪个应用程序的字典已经太晚了。

票数 3
EN

Stack Overflow用户

发布于 2014-12-27 10:59:04

你可以用"using terms from...“来包装它。块,如下所示:

代码语言:javascript
复制
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测试了一下;

代码语言:javascript
复制
set thePathToDistiller to "/Applications/iTunes.app"
using terms from application "iTunes"
    tell application thePathToDistiller
        playpause
    end tell
end using terms from

这是可行的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27663893

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档