CHAPTER 1
Introduction to Finder Scripting
Writing Scripts That Control the Finder 11
Listing 1-2 A script that either takes a snapshot of the current window arrangement
or restores a previously stored snapshot
property boundsAll : {}
property refsAll : {}
set dialogResult to display dialog ¬
"Restore old snapshot or take new one?" ¬
buttons {"Restore Old Snapshot", "Take New Snapshot"}
if button returned of dialogResult is "Restore Old Snapshot" then
tell application "Finder"
close windows
set increment to 0
repeat (number of items in refsAll) times
set increment to increment + 1
set i to item increment of refsAll
open i
set x to item increment of boundsAll
set bounds of window 1 to x
end repeat
end tell
else
tell application "Finder"
set boundsAll to the bounds of every window
set refsAll to the item of every window
end tell
end if
To keep this script handy, store it as a script application on the desktop. When-
ever you want to record or restore a window arrangement, double-click the
application’s icon. If you want to be able to switch back and forth between
several window arrangements, duplicate the script and use each copy to create
and store a different one.
Comments to this Manuals