0

我有一个看起来像这样的applescript:

repeat
   tell application "Adobe Reader"
     open "filepath/name.pdf"
    end tell

    delay (60)

   tell application "Adobe Reader"
     open "filepath/name1.pdf"
    end tell

    delay (60)

   tell application "Adobe Reader"
     open "filepath/name2.pdf"
    end tell

    delay (60)

end repeat

我希望能够在打开 pdf 窗口后关闭它们。问题是这些 pdf 文件驻留在共享中,用户可以更新它们。该脚本仅在停止并重新启动时才会显示更新的 pdf。我不想手动执行此操作。我怎样才能做到这一点?

4

1 回答 1

0

这是一个解决方案,它使预览可编写脚本,然后继续打开和关闭您选择的文件。

-- http://www.macworld.com/article/1053391/previewscript.html
on addAppleScriptFeatures()
  try
    tell application "Finder"
      set the Preview_app to (application file id "com.apple.Preview") as alias
    end tell
    set the plist_filepath to the quoted form of ¬
      ((POSIX path of the Preview_app) & "Contents/Info")
    do shell script "defaults write " & the plist_filepath & space ¬
      & "NSAppleScriptEnabled -bool YES" with administrator privileges
    do shell script "chmod -R 755 " & the quoted form of (POSIX path of the Preview_app) with administrator privileges
    return true
  on error myErr number MyNr
    display dialog myErr & " (" & MyNr & ")." buttons {"OK"} default button "OK" with icon 0
    return false
  end try
end addAppleScriptFeatures

if addAppleScriptFeatures() then
  set f to choose file
  tell application "Preview"
    activate
    open f
    delay 5 -- short for testing
    close window 2
  end tell
end if
于 2013-06-05T09:27:38.180 回答