AppleScript_ The Definitive Guide - Matt Neuburg [198]
file selection dialog
Puts up a standard Open File dialog, with title "Choose File" and default button "Choose." You can add a prompt; you can set the initial folder displayed. You can specify whether invisible files should be shown, whether packages should be treated as folders, and what types of file to display (can be a list of either four-letter file type codes or UTIs—see http://developer.apple.com/macosx/uniformtypeidentifiers.html—but not both). Returns an alias.
Example
set f to choose file of type {"public.text"} without invisibles
Name
choose folder
Synopsis
folder selection dialog
folder selection dialog
Puts up a standard Choose Folder dialog, with title "Choose a Folder." The user can also create a new folder. Your options are similar to choose file. Returns an alias.
Example
set f to choose folder with prompt "Pick a folder:"
Name
choose file name
Synopsis
file save dialog
file save dialog
Puts up a standard Save File dialog (default button "Save"), with title "Choose File Name" and default prompt "Specify new file name and location." The user can also create a new folder. If the user specifies an existing file, goes through the usual "Replace?" rigmarole. You can set the initial folder, the initial filename, and the prompt. Returns a file URL (which appears as a file specifier). Does not actually save anything.
Example
set f to choose file name with prompt "Where shall I save this stuff?"
Name
choose application
Synopsis
application selection dialog
application selection dialog
Puts up a standard Choose Application dialog, listing all applications, with title "Choose Application" and default prompt "Select an application." The user can switch to browsing in a standard Open File dialog. You can specify the window title and prompt. Returns an application specifier, or optionally an alias, or a list if multiple selections are allowed.
Example
set theApp to choose application as alias
tell application "Finder"
set isScriptable to has scripting terminology of theApp
end tell
if isScriptable then display dialog "It's scriptable!"
Name
choose URL
Synopsis
URL selection dialog
URL selection dialog
Puts up a standard Choose URL dialog (with a Connect button); this is rather like the Finder's Connect to Server dialog, useful for finding servers on the local network, with an option to let the user choose various categories of server. The user can also just type a URL unless you prevent it; this can be basically any string at all. Does not actually connect! Returns a string.
Example
choose URL showing File servers -- "afp://duck.local."
Name
choose remote application
Synopsis
remote application selection dialog
remote application selection dialog
Puts up a dialog with title "Choose Remote Application" and two panes, one for selecting a local machine or entering an IP number, the other with default prompt "Select an application." The target machine must have Remote Apple Events turned on in the Sharing system preferences. I have not been able to get the local-machine choice to work (where the Bonjour names of local machines are listed automatically) but using the IP number works, and a Bonjour name can be entered manually. You can supply the title and prompt. Returns an eppc URL string suitable for targeting the application remotely; see Chapter 23. (New in Tiger.)
Examples
choose remote application
-- application "Finder" of machine "eppc://192.168.0.4/?uid=501&pid=178"
using terms from application "Finder"
set ap to choose remote application -- I choose Finder on remote machine
-- username/password dialog appears, I fill it out
tell ap
get name of window 1 -- Desktop
end tell
end using terms from
Name
choose color
Synopsis
color selection dialog
color selection dialog
Puts up a standard Color Picker dialog, where the user may choose a color. You can specify the initially selected color. Returns a color. A color is expressed as an rgb color, which is a list of three integers representing