First Foray Into AppleScript
Posted by Antoine Quint apropos on Sun Jul 25th, 2004 at 19:59:19 BST
My favorite editor, SubEthaEdit, did not provide a way to have all the different document windows stacked onto one another (at least none that I could tell of). So it sprang my first foray into AppleScript.
It took me a while just to figure how to get the script menu to appear at all, to begin with. Looks like all you have to do is go in your /Applications/AppleScript folder and run the small Install Script Menu program. This will get the AppleScript icon to show up in the right part of the task bar, the part that's governed by the system.
Then, you have to create a folder by the name of the application you want to make your script available to within ~/Library/Scripts/Applications. So I created the ~/Library/Scripts/Applications/SubEthaEdit folder. I then opened Script Editor to get the script started. Here it is:
set currentApp to (path to frontmost application as Unicode text)
tell application currentApp
set screenY to item 2 of screen size of item 1 of (screen list starting with main screen)
set allWindows to (every window where visible is true)
set n to count of allWindows
if (n > 0) then
repeat with i from n to 1 by -1
tell window i
set {x1, y1, x2, y2} to (get bounds)
set w to x2 - x1
set h to y2 - y1
set x to 10
set y to (screenY - h) - 30
set bounds to {x, y, w + x, h + y}
end tell
end repeat
end if
end tell
You'll also need the latest version of Jon Pugh's Commands X extension library. This library provides a way to access screen size and depth, and other nice things about your system. I think you'll also need to compile it if you want it to run from the task bar menu.
This is my first script, so I'm pretty sure it can be made better, but at least "it just works"!
- Create an account
- About SVG.org
- Frequently Asked Questions
- SVG.org Content with RSS

- Get SVG Help on IRC
- SVG.Open Conferences
- SVG Phones (169 and counting)
- JSR 226 Phones (28 and counting)
