簡體   English   中英

AppleScript關閉PDF窗口

[英]applescript to close pdf window

我有一個如下的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。 我不想手動執行此操作。 我怎樣才能做到這一點?

這是一個解決方案,使Preview可以編寫腳本,然后繼續打開和關閉您選擇的文件。

-- 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM