Online Book Reader

Home Category

AppleScript_ The Definitive Guide - Matt Neuburg [199]

By Root 1449 0
the red, green, and blue components.

Example

choose color default color {9000, 10000, 50000} -- {50000, 9000, 10000}

Name

beep

Synopsis

beep

beep

Plays the system beep sound. Optionally takes an integer saying how many times to beep.

Example

beep

Name

get volume settings

Synopsis

sound loudness report

sound loudness report

Reports the loudness of sound output, input, and alert volume, as a record.

Example

alert volume of (get volume settings) -- 75

Name

set volume

Synopsis

sound loudness setting

sound loudness setting

Sets the loudness of sound output, input, and alert volume.

Example

set volume output volume 100 alert volume 100

beep

Name

say

Synopsis

text-to-speech

text-to-speech

Reads text aloud, either in real time or saving the synthesized speech as a sound file. Can also be used in conjunction with speech recognition to determine what text appears below the microphone window .

Example

tell application "SpeechRecognitionServer"

set s to listen for {"yes", "no"} with prompt "Would you like me to beep?" ¬

giving up after 10

end tell

if s is "yes" then

say "Okay, I will beep now." displaying "Okay."

beep

else

say "Okay, then I won't." displaying "Okay."

end if

Name

system info

Synopsis

system information

system information

Returns a record of basic system information, such as the computer name , CPU speed and type, Ethernet address, and so forth (new in Tiger). If the desired information is not part of this record, use the more general (but harder to use) system attribute command.

Example

set v to system version of (system info)

display dialog "You are running system " & v & "!"

Name

system attribute

Synopsis

gestalt and environment variables

gestalt and environment variables

Returns the value of gestalt selectors (see http://developer.apple.com/documentation/Carbon/Reference/Gestalt_Manager/index.html ).

Example

set n to system attribute "sysv"

set s to "print sprintf \"%lx\", " & n

set v to do shell script "perl -e " & quoted form of s

set L to characters of v

set v to "." & item -1 of L

set v to "." & item -2 of L & v

set v to ((items 1 thru -3 of L) as string) & v

display dialog "You are running system " & v & "!"

Also returns the value of user environment variables (see Chapter 25 for an example ). To find out what they are, issue the system attribute command with no parameters.

Example

system attribute "SHELL" -- "/bin/bash"

Name

path to

Synopsis

standard folder location

standard folder location

Locates various standard folders, such as the system folder. If the designated folder is legal but doesn't exist, the path to command silently creates it unless you specify without folder creation, in which case an error is returned if the folder doesn't exist. If a standard folder isn't listed as an enumerator, you can use its four-letter code (see http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/index.html ). Returns an alias, or a string, if desired (or Unicode text—the dictionary fails to document this fact).

Example

path to desktop -- alias "feathers:Users:mattneub:Desktop:"

path to "cmnu" -- alias "feathers:Library:Contextual Menu Items:"

Name

path to

Synopsis

application and script file location

application and script file location

Locates an application by name, including the current application (the host application). Launches the application if it uses Cocoa scripting (I regard this as a bug). The special phrase path to me is supposed to give the alias of the current compiled script file, but in the past this has been unreliable; it is somewhat better in Tiger, though it can still go wrong depending on the script runner environment and the script file format (script bundles are problematic), and it doesn't work in Script Editor (works fine in Script Debugger).

Example

path to application "Finder"

-- alias "feathers:System:Library:CoreServices:Finder.app:"

Name

path to resource

Synopsis

bundle

Return Main Page Previous Page Next Page

®Online Book Reader