Apple AppleScript Finder Guide User Manual Page 21

  • Download
  • Add to my manuals
  • Print
  • Page
    / 168
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 20
CHAPTER 1
Introduction to Finder Scripting
Recording Actions in the Finder 9
integers. For the Position property, the two integers specify the coordinates of
the upper-left corner of the content region of the window (the portion of the
window that displays its contents; the title bar and scroll bars are not part of the
content region). For the Size property, the two integers specify the vertical and
horizontal dimensions of the window’s content region.
Instead of adjusting these properties separately, you can adjust them at the
same time by setting the Bounds property. The value of the Bounds property is
a list of four integers that specify the coordinates of the four corners of the
window’s content region. The first and second integers are identical to the
value of the window’s Position property. The third and fourth integers can be
obtained by adding the first and second integers of the Position property to the
first and second integers of the Size property, respectively.
You can easily obtain the bounds property of a window by asking the Finder
for it. Just activate the window and run a script like this:
tell application "Finder"
bounds of front window
end tell
--result: {4, 43, 373, 507}
If you wish, you can rewrite a script like the one in Listing 1-1 using the
Bounds property instead of Position and Size:
tell application "Finder"
activate
close every window
open startup disk
set bounds of window of startup disk to {4, 43, 373, 507}
open folder "Financial" of startup disk
set bounds of window "Financial" to {378, 43, 578, 198}
open folder "Letters" of startup disk
set bounds of window "Letters" to {379, 222, 579, 508}
end tell
Although this simplified version of the script in Listing 1-1 won’t run
appreciably faster than the original, it is easier to read. In a longer script,
using succinct statements can improve performance.
Page view 20
1 ... 20 21 22 ... 168

Comments to this Manuals

No comments