如何使用AppleScript在预览中打开文档的路径?

Abh*_*bhi 4 applescript

我试过这个,但它不起作用:

tell application "Preview"
    set myfile to path of document 1 of window 1
end tell
Run Code Online (Sandbox Code Playgroud)

我已经验证我的预览是可编写脚本的(NSAppleScriptEnabled).

mcg*_*ilm 8

我做了一点研究,发现了这一点

 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 & "\");'"
Run Code Online (Sandbox Code Playgroud)

我在macscripter上找到了