Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 2 - Finder Objects / The Finder Application Object


References to Finder Windows

One of the Finder elements you can refer to in scripts is a content space, which can be any kind of window or the desktop. If you request all the content spaces, the Finder returns a list of references to all kinds of windows (container windows, information windows, sharing windows, and status windows)
and the desktop:

tell application "Finder"
   content spaces
end tell

--result: {information window of startup disk of 
application "Finder", window of folder "Projects" of 
startup disk of application "Finder", window of startup 
disk of application "Finder", window of disk "Applications" 
of application "Finder", content space of desktop of 
application "Finder"}
The result shown in the preceding example includes one information window, three container windows, and the desktop content space. An information window is the window that opens when you select an object's icon in the Finder and choose Get Info from the File command. Containers are objects that can hold other objects, such as suitcases, folders, disks, and the desktop, and a container window is a window that belongs to a container. The only exception is the desktop window. Even though the desktop is a container, the desktop content space is a special case and the Finder doesn't consider it a member of class Window (although you can refer to window of desktop in a script).

The desktop "window" and the desktop are actually the same object, whereas all other windows are distinct from the objects they belong to and may have different properties. For example, the Position property of a disk is different from the Position property of the disk's window.

The desktop doesn't have most of the characteristics of windows, so you can't refer to properties such as Bounds, Position, and so on. If you are performing operations on Finder windows that involve these properties, you may want to get a list of windows that doesn't include the desktop. Therefore, the Finder doesn't include the desktop when you request a list of windows:

tell application "Finder"
   windows
end tell

--result: {information window of startup disk of 
application "Finder", window of folder "Projects" of 
startup disk of application "Finder", window of startup 
disk of application "Finder", window of disk "Applications" 
of application "Finder"}
The list of window references returned doesn't include the desktop, but it does include information windows and any other windows that are open. If you want to get a list restricted to windows that belong to containers, request a
list of container windows:

tell application "Finder"
   container windows
end tell

--result: {window of folder "Projects" of startup disk of 
application "Finder", window of startup disk of application 
"Finder", window of disk "Applications" of application 
"Finder"}
You can refer to windows by name, by number, or as the window property of the object to which they belong. For example, these statements are equivalent:

window "My Folder"
window of folder "My Folder" of startup disk
These statements are also equivalent:

window 1
front window
The Finder's front window isn't necessarily the active content space, which can be the desktop as well as a window. To get a reference to the active content space, use this statement:

content space 1

Subtopics
References Returned for the Insertion Location property
References Returned for a Point

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996