我都试过,但它不工作:如何在使用AppleScript的预览中打开文档的路径?
tell application "Preview"
set myfile to path of document 1 of window 1
end tell
我已经验证了我的预览编写脚本(NSAppleScriptEnabled)。
我都试过,但它不工作:如何在使用AppleScript的预览中打开文档的路径?
tell application "Preview"
set myfile to path of document 1 of window 1
end tell
我已经验证了我的预览编写脚本(NSAppleScriptEnabled)。
我做了一些研究,发现这
tell application "System Events"
tell process "Preview"
set thefile to value of attribute "AXDocument" of window 1
end tell
end tell
-- macos comes with php installed you can decode this file name using php
return do shell script "php -r 'echo urldecode(\"" & thefile & "\");'"
在我的10.6系统预览版没有Applescript词典。这是可编写脚本的应用程序所需要的。虽然预览声明它可以做Applescript,但它确实不能。
它没有办法将“窗口1的文档1的路径”翻译成任何有意义的东西。
通常人们使用GUI脚本与Preview进行交互,或者他们找到另一种方式。
这解决我的问题找到。谢谢! – Abhi 2010-04-07 19:52:28
欢迎Abhi – mcgrailm 2010-04-08 01:04:35
不幸的是,这给urlencoded'thefile' AppleScript没有本地urldecode函数。 – mb21 2013-05-25 18:15:48