activate application "Preview"
tell application "System Events" to tell application process "Preview"
title of every window
--> {"Hȁussermȃn.pdf (page 1 sur 3)"}
set theURL to value of attribute "AXDocument" of window 1
(*
Leaves theURL undefined if the document was never saved before.
If the doc was saved once, returns something like
end tell
try
decode_URL(POSIX file theURL as text)
--> "Macintosh HD:Users:yvankoenig:Desktop:Hȁussermȃn.pdf"
on error
"never saved"
end try
on decode_URL(txt)
return do shell script "/usr/bin/python -c " & ¬
quoted form of "import sys, urllib; print urllib.unquote(sys.argv[1])" & space & ¬
quoted form of txt
end decode_URL