Launch Script Editor

AppleScript Studio: Center all windows and panels

Your application may use several windows and panels. The main window, the search panel, the progress panel and so on.

The user can move them freely on the screen and it's a good practice to save and remember those positions.

But if for any reason you want to reset the windows positions and center them, there's a sweet little command to do it:

tell every window to center

This will affect visible and hidden windows (and panels). You can call it on the awake from nib handler to center at startup.

It may be useful in a multi-screen computer, to rejoin all windows on the main display.

Prompt user for a file and read it

set fileContents to read (choose file)

Yes, just that.

Studio: Disable all controls (buttons) of the window

When coding your ApplesScript Studio application, sometimes it's useful to disable all the window's controls. By "controls" I mean every clickable piece, like buttons, popups, sliders and matrices.

You may want to disable them to avoid user clicks for a short time period, when some processing is occurring or when the application is not yet ready to handle these clicks. It's just a single line:

set enabled of every control of window 1 to false

To restore all the controls, just change the last word to true. I know you knew it :)

Remember: always consider the every magic keyword when you need to apply something to a group of elements.

Reverse of a string (invert/transpose text)

reverse of "ABCDEF"
-- Error

characters of "ABCDEF"
-- Returns: {"A", "B", "C", "D", "E", "F"}

reverse of characters of "ABCDEF"
-- Returns: {"F", "E", "D", "C", "B", "A"}

reverse of characters of "ABCDEF" as text

Get the list of folders inside a folder

tell application "Finder"
    get name of folders of folder ("/Library/Desktop Pictures/" as POSIX file)
    
    -- Returns: {"Abstract", "Black & White", "Nature", "Plants", "Solid Colors"}
    
end tell


tell application "Finder"
    get name of folders of folder "Library:Desktop Pictures" of startup disk
    
    -- Returns: {"Abstract", "Black & White", "Nature", "Plants", "Solid Colors"}