Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Adobe Reader has N documents open. One of them has a known filepath and title and it needs to be programmatically closed. How to go about doing this in AppleScript? Specifically, how can I:

  • Talk to Reader
  • Access a list of documents currently opened
  • Select the document I need to close among the list above (I know: document path on the filesystem and document title, not necessarily "position" (e.g. frontmost, background, 3rd tab, or similar) or order in which it was opened)
  • Give Reader the command to close the file, not changing the active/frontmost document if the document to close was not in front of the user. Remembering which one was active, quickly switching to the one to close and back to the previous one is acceptable if it can be done almost imperceptibly

Hopefully this is a precise definition of the task, thanks for your help.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

"Adobe Reader" is not really scriptable, you can't access to the objects (window, document), but You can use the GUI Scripting.

This script works well here.

set theTitle to "this name.pdf"

tell application "System Events"
    tell process "Adobe Reader"
        tell window theTitle to if exists then perform action "AXPress" of (get value of attribute "AXCloseButton")
    end tell
end tell

This script requires that you enable access for assistive devices in the Universal Access System Preference pane.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.