我都試過,但它不工作:如何在使用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