beautypg.com

Apple AppleScript Finder Guide User Manual

Page 31

background image

C H A P T E R 2

Finder Objects

The Finder Application Object

19

To obtain a standard reference to an element of the Finder while you’re writing

a script, follow these steps:

1. Select the object.

2. Choose Copy from the Edit menu.

3. Activate the Script Editor application.

4. Click at the point in your script where you want to paste the reference.

5. Choose Paste Reference from the Edit menu.

Windows are also elements of the Finder application. You can address a Tell

statement to a Finder window anywhere in a script:

tell front window of application "Finder"

close

end tell

Because window is a standard AppleScript term, AppleScript can interpret this

script correctly. However, when it compiles a script, AppleScript doesn’t look

up the Finder’s terminology definitions until after it has compiled the first line

of the first Tell statement that addresses the Finder. Therefore, a script that

consists of a Tell statement addressed to any other Finder object won’t compile:

tell startup disk of application "Finder"

open

end tell

To address a Tell statement to a Finder object other than a window, enclose it

within another Tell Statement, like this:

tell application "Finder"

tell startup disk

open

end tell

end tell