How to get the way to open a document in Preview using AppleScript?

I tried this, but it does not work:

tell application "Preview" set myfile to path of document 1 of window 1 end tell 

I verified that my Preview is scriptable (NSAppleScriptEnabled).

+4
source share
2 answers

I did a little research and found this

  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 & "\");'" 

which i found on macscripter

+7
source

There is no Applescript dictionary on my 10.6 Preview system. This is what scripting needs. Although Preview SAYS, it can do Applescript, it really cannot.

It is not possible to translate the "path to document 1 of window 1" into anything meaningful.

Usually people use a graphical interface to interact with the preview, or they find another way.

+2
source

Source: https://habr.com/ru/post/1303294/


All Articles