O'Reilly logo

AppleScript in a Nutshell by Bruce W. Perry

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Help Viewer

Synopsis

Since Help Viewer (see Figure 10-2) is essentially a browser, you can open up any local hypertext markup language (HTML) file with it (see the open command for Help Viewer). AppleScripters can thus use this program to either provide their scripts with their own HTML-based help systems or provide an alternate and perhaps quicker avenue to the Mac OS’s help files.

A Help Viewer window
Figure 10-2. A Help Viewer window

Syntax

tell app "Help Viewer"
   (* get the app to print various help topics or open HTML files here *)
end tell

Dictionary commands

Open alias list

One of the ways to open up a help file in Help Viewer is to send it an open Apple event with a list of aliases as a parameter (one alias, representing the file path to the page you want to open). The following example opens a page on Help Viewer search tips. You can also use open to open your own HTML files in Help Viewer, as long as you make sure to save the file path as an alias inside of a list (as in {my_alias}) before passing this parameter to open :

tell application "Finder"
   (* path to the Help Viewer tips file *)
   set tips to 
      ((system folder as string) & "help:apple help
   viewer:hvtps.¬
      htm") 
      as alias
end tell
tell application "Help Viewer"
   activate -- bring it to the fore
   open {tips} -- use open followed by a list with one alias
end tell

Print alias list

You can use code similar to the prior example to send a print ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required