beautypg.com

Apple AppleScript Finder Guide User Manual

Page 37

background image

C H A P T E R 2

Finder Objects

The Finder Application Object

25

References Returned for a Point

2

To get a reference to the content space that lies under a particular point on the

desktop, run a script like this:

tell application "Finder"

content space {100, 100}

end tell

--result: window of folder "Projects" of startup disk of
application "Finder"

The pair of integers in braces identifies the point in which you’re interested

relative to the entire screen (including the menu bar), and the result contains

a reference either to a window or to the desktop. It is usually easiest to use the

term Content Space to obtain this kind of reference, because the script returns

a reference even if the point is located in the desktop window.
You can also specify more restricted window classes, such as Window,

Container Window, Information Window, and so on, as shown in the

next example.

tell application "Finder"

container window {100, 100}

end tell

The script in this example returns a reference only if a container window

contains the specified point. If the specified point is located in some other

kind of content space, such as the desktop or an information window, the

script returns an error.
You can use similar methods to find out whether an item or other object lies

under a particular point. For example, this script returns a reference to an item

if the item’s bounds enclose the specified point:

tell application "Finder"

item {100, 100}

end tell