我们有一个applescript,它告诉keynotes根据条件删除幻灯片。新注释记号没有applescript字典,但将旧注释记号保留在子目录中。所以我试着告诉AppleScript使用旧的应用程序而不是新的应用程序。
如果我只是
tell application "Clean Install:Applications:iWork '09:Keynote.app"它可以工作,但它不能识别任何keynote字典术语。(删除幻灯片)。所以我需要把我的老朋友"using terms from“拉出来。这里的挑战是这是一个预编译指令,所以您必须使用字符串文字,而我在最终用户的机器上没有,因为硬盘驱动器名称不同。
好吧,这里还是有个计划的。我将写出一个新的applescript文件,文件名为“using terms from application "Clean Install:Applications:iWork‘09:Keynote.app”,然后执行该文件...天才..。除了这样一个事实:当AppleScript编译这行代码时:
using terms from application "Clean Install:Applications:iWork '09:Keynote.app"更改为:
using terms from application "Keynote"它当然会调用新的keynote的字典,这个字典是空的。
有什么想法可以让applescript不再以这种方式帮我吗?(或者有更好的计划?)
完整代码:
using terms from application "Clean Install:Applications:iWork '09:Keynote.app"
--using terms from application "Clean Install:Applications:iWork '09:Keynote.app"
tell application "Clean Install:Applications:iWork '09:Keynote.app"
activate
end tell
end using terms from非常感谢!
发布于 2013-11-12 01:31:41
我在这里是盲目的(没有主题演讲) ...但是,您是否尝试过使用预定义的应用程序字符串作为变量和原始事件代码?
您可以使用Smile通过以下方式轻松获取原始事件代码
H19将该原始事件代码粘贴到另一个窗口中,该窗口包含您的正常(正常tell块)脚本H210F211
这是我为Mail应用程序执行此操作时的样子:
set origMail to "MyDrive:Applications:Mail.app"
tell application origMail
delete («class mssg» 1 of «class mbxp» "INBOX" of «class mact» 1)
end tell(当放入普通的tell块时,该行代码将是"delete (message 1 of mailbox "INBOX“of account 1)”)
发布于 2013-11-12 03:36:50
我还没有试过,但我想它会起作用的。当你用"using terms from“编译你的代码时,只要把你的新版本的Keynote放在垃圾桶里就行了。这应该会强制它使用旧版本的Keynote字典,您的代码应该会被编译。如果您随后将该代码保存为"applescript应用程序“,那么它应该可以在任何人的计算机上运行,而不需要重新编译。注意:您可能需要重新启动计算机,此技巧才会起作用。
然后,您就会遇到在用户计算机上定位正确应用程序的问题,因为它们也可能同时具有两个版本。下面是一些代码,可以找到旧版本的Keynote的路径,以及如何定位该路径。
set lsregister to "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister"
set appName to "Keynote.app"
set nonapplescriptVersion to "6.0"
-- get the path to all Keynote apps
set appPaths to paragraphs of (do shell script lsregister & " -dump | grep " & quoted form of appName)
-- find the one with a version number less than the nonapplescriptVersion of Keynote
set appPath to missing value
repeat with anApp in appPaths
try
-- extract the path
set AppleScript's text item delimiters to "/"
set tis to text items of anApp
set thisPath to "/" & (items 2 thru end of tis) as text
set AppleScript's text item delimiters to ""
-- check the version
if (version of application thisPath) is less than nonapplescriptVersion then
set appPath to thisPath
exit repeat
end if
end try
end repeat
if appPath is missing value then error "Needed application version not installed."
-- use the older version
using terms from application "Keynote"
tell application appPath
activate
-- do whatever
end tell
end using terms fromhttps://stackoverflow.com/questions/19910517
复制相似问题