Hardware Reference
In-Depth Information
Tell me how many files and folders are on my Desktop:
tell application "Finder"
set theFolder to (path to desktop) as string
set theCount to number of items in folder theFolder
display dialog (theCount)
end tell
Speak the current date:
set theDate to current date
set theYear to year of theDate
set theMonth to month of theDate
set theDay to day of theDate
set niceDate to theMonth & " " & theDay & ", " & theYear as text
say niceDate
Resize the frontmost Safari window:
tell application "Safari"
activate
if front window exists then
set bounds of front window to {0, 0, 1000, 600}
else
display dialog ("Safari has no open windows.")
end if
end tell
A quick Web search should turn up thousands of additional AppleScripts you can use—and I
refer you to some additional sources ahead, in Learn More about AppleScript .
YoucanalsofindabunchofsamplescriptsalreadyonyourMac,inthe /Library/Scripts
folder. You'll notice that those scripts—and perhaps many of those you find online—aren't
just text; they're AppleScript files . One way to use them is to double-click the file (which
opens them in AppleScript Editor) and then click the Run button. But that's not the only
way!
Another way to access an AppleScript saved as a file is to choose its name from the
AppleScript menu ( Figure 38 ). Don't see it? Open AppleScript Editor, go to AppleScript
Editor > Preferences > General, and select the Show Script Menu in Menu Bar checkbox. By
default, that shows all the scripts in /Library/Scripts as well as ~/Library/Scripts ,
so you can add to the menu by placing your scripts in one of those folders (or a subfolder).
Search WWH ::




Custom Search