我正在尝试制作两个AppleScript副本,一个适用于Entourage,另一个适用于out Outlook。我只在当前计算机上安装了Entourage。
根据微软网站上的信息,这两个应用程序都有相同的AppleScript命令库,我应该能够简单地更改脚本中引用的应用程序名称。
更改:
Tell application "Microsoft Entourage"至
Tell application "Microsoft Outlook"阻止我保存脚本,因为我没有在这台计算机上安装outlook。有什么办法可以解决这个问题吗?我是否需要使用文本编辑器来编辑实际的脚本文件并在其中进行更改?
谢谢!
发布于 2011-06-11 01:43:42
下面的变通方法可能会解决这个问题。在安装了Entourage的计算机上,即使没有安装using terms,也可以使用Outlook指令编译脚本:
set theApp to a reference to application "Microsoft Outlook"
using terms from application "Microsoft Entourage"
tell theApp
get version
...
end tell
end using terms from在编译和保存脚本时,Outlook会向您报告缺少的AppleScript应用程序,但它仍然会生成一个已编译的AppleScript文件(.scpt)。
发布于 2011-06-10 21:06:47
Applescript是一种预编译的文件格式,这意味着每次单击“保存”时,它都会运行一系列步骤,以确保脚本能够工作,但实际上并不是真正运行脚本的逻辑。这些步骤的一部分是查找应用程序,看看它是否存在于Mac上。
简而言之,如果您想将脚本另存为Applescript,则需要安装目标应用程序,否则您可以将脚本另存为文本文件,然后将文件移动到目标Mac以在目标Mac上另存为Applescript。
发布于 2011-06-18 14:24:26
应该可以创建一个可以同时使用Entourage和Outlook的脚本,而不会在编译或运行时找不到的情况下困扰您。我既没有Entourage也没有Outlook,但它应该是这样工作的:
using terms from application "Microsoft Entourage"
script theScript
tell application "Finder" to try
set theApp to application file id "Entourage's Bundle ID" as text
on error
set theApp to application file id "Outlook's Bundle ID" as text
end try
tell application theApp
-- do stuff
end tell
end script
end using terms from
store script theScript in "MyScript.scpt""using terms from“只有在编译脚本时才有意义--在运行时不需要,尽管出于某些原因,如果找不到该应用程序,您仍然会被窃听。因此,通过将其包装在脚本对象周围,然后将该脚本写出到文件中,生成的脚本仍将运行,但不会包含"using terms from“,因此不会对用户造成错误。
为了获得正确的应用程序的引用,Finder可以通过ID查找它,如果找不到它,就会简单地出错,而不是困扰用户。你需要在那里插入正确的ID,我不知道它们是什么。
https://stackoverflow.com/questions/6301435
复制相似问题