DekGenius.com
Team LiB   Previous Section   Next Section
Appearance Control Panel

Syntax

tell app "Appearance" to get picture file of monitor 1 (* returns "no 
picture" if the desktop has a color but not a picture *)

Dictionary commands

count

This command returns an integer representing a count of certain Appearance objects, such as:

count of monitors

or:

count of themes

You can also use the syntax count each theme or count each monitor.

exists

This indicates whether an object exists and returns a boolean value, as in:

exists monitor 2

This command returns false if the machine is hooked up to only one monitor.

quit

This quits the Appearance application:

tell app "Appearance" to quit
run

This command sends a run Apple event to Appearance, which opens the application if it is not already open. Using this command is not necessary as AppleScript sends an implicit run command to the applications that are targeted in a tell statement. Chapter 7, describes the tell statement.

Dictionary classes

Application

The Appearance Application class has two elements: theme and monitor. There are in reality about two dozen theme objects associated with each Appearance application and one or more monitors (depending on how many monitors are attached to your machine). The Application class has the following properties (appearing here in their Dictionary order), all of which are accessible by targeting the Appearance app in a tell statement. The properties are accompanied by their data type in parentheses:

name (string)

This represents the application's name, as in "Appearance."

frontmost (boolean)

This returns true if Appearance is the active application on the desktop (i.e., its window is highlighted).

version (version type, like a string)

Use this property, as in

tell app "Appearance" to get version

to find out the control panel's version on the machine. You'll have to coerce the version property to a string to pass it to the display dialog osax:

version as string
current theme (reference)

This is a reference to the selected theme under the Theme tab of the control panel. You can use this property to get information on the current theme:

name of current theme
appearance (string)

This property corresponds to the Appearance pop-up menu under the control panel's Appearance tab. This is the name for the overall look of icons, menus, and other desktop elements, as in "Apple platinum."

appearance variant (string)

This property corresponds to the Variation pop-up menu under the control panel's Appearance tab. It returns a string such as "Lavender," representing another variation on the desktop appearance (the dictionary entry of an integer return value is wrong).

background pattern (international text)

This property corresponds to the Patterns list box under the control panel's Desktop tab. It returns the pattern name like "Azul Dark."

highlight color (string)

This property represents the Highlight Color pop-up menu under the control panel's Appearance tab. You can dynamically change the computer's highlight color for text with code such as set highlight color to "Azul".

highlight color (RGB color)

You can also pass an RGB Color value to this property to alter the color to a custom hue. RGB Color values are list types with three numbers ranging from to 65535; the integers represent the red, green, and blue components for the custom color. For example, get highlight color as RGB color would return {39321,52428,65535}, which represents the color Azul. Chapter 3, discusses AppleScript's value types like list.

minimum font smoothing size (integer)

This corresponds to the "Smooth all fonts on screen" checkbox in the Fonts tab of the control panel. It returns an integer representing the minimum-sized font for which the computer will turn on anti-aliasing, a graphics term for smoothing the jagged look of some fonts on the computer screen.

system font (international text)

This property returns the name of the font your system is using, such as "Charcoal." It corresponds to the Large System Font pop-up menu choice in the control panel's Fonts tab.

small system font (international text)

This property returns the name of the font your system is using for displaying small text items. It corresponds to the Small System Font pop-up menu in the control panel's Fonts tab.

views font (string)

This property contains the name of the font the machine is using for views, such as folder listings. An example views font value is "Geneva." It corresponds to the Views Font pop-up menu choice in the control panel's Fonts tab.

views font size (integer)

This is the property for the size of the views font, which is an integer (e.g., 10).

font smoothing (boolean)

This is a true or false value indicating whether font smoothing is on.

scroll box style (fixed/proportional)

This property corresponds to the Smart Scrolling checkbox in the Options tab. Unchecked enables fixed, and checked is proportional. To find out what kind of scroll box setting you have, use code such as:

get scroll box style

which returns either fixed or proportional.

scroll bar arrow style (single/both at one end).

Checking Smart Scrolling in the control panel's Options tab gives your windows both up and down arrows at the bottom of each window scroll bar. Control this with AppleScript code such as the following:

set scroll bar arrow style to single
Single

This produces a single arrow at the top and bottom of the scroll bar. If Smart Scrolling is checked then this value is both at one end.

collapsible via title bar (boolean)

This property, a true or false value, determines whether clicking on a window's title bar makes the window itself disappear or collapse, except for the title bar. The property corresponds to the "Double-click title bar to collapse windows" checkbox in the Options tab.

sound track (no sound track/string)

Checking this property returns either the constant no sound track or a string like "Platinum Sounds." This property corresponds to the pop-up menu in the control panel's Sounds tab.

sound effects (list of constants: menu sounds/control sounds/window sounds/finder sounds)

You can control which desktop elements (e.g., menus, windows) play sounds when you manipulate them by setting the sound effects property to a list of constants such as:

{menu sounds, control sounds}

If sound track is set to no sound track, then setting the sound effects property does not have a practical effect (you still won't have any sounds).

theme

This class encapsulates an individual theme in your Appearance settings. The Appearance application's current theme property returns a reference to an enabled theme object. The theme class has zero elements and the following nine properties. All of these properties are the same as the Application properties, except that they are read-only; you cannot change their values.

name (string; read-only)
appearance (string; read-only)
appearance variant (string; read-only)
background pattern (international text; read-only)
highlight color (RGB color; read-only)
system font (international text; read-only)
small system font (international text; read-only)
views font (international text; read-only)
views font size (integer; read-only)
Monitor

This class represents the monitor(s) attached to the computer. It has zero elements and the following two properties:

picture file (no picture/alias)

This either returns the value no picture (a constant type, not a string) or an alias to the picture (which can be coerced to a string, as in "Macintosh HD:pics:sunset.jpg").

picture positioning (automatic/tiled/centered/scaled/filling)

This is a constant value specifying how to display the picture file on the desktop.

Examples

global theMessage
tell application "Appearance"
   (* boolean variables *)
   set MyCollapsible to false
   set ScrollBoth to false
   (* test 'collapsible via title bar' property *)
   if collapsible via title bar then set MyCollapsible to true
   (* check 'scroll bar arrow style' property: can be either 'single' or 'both at one end' *)
   if scroll bar arrow style is both at one end then
      set ScrollBoth to true
   end if
   set theMessage to¬
   "You can double-click the title bar to collapse the windows: " &¬
   MyCollapsible & return
   set theMessage to theMessage &¬
   "The scroll bars have the arrows at one end: " & ScrollBoth &¬
   return & return
   set theMessage to theMessage & "The current theme is: " &¬
   (name of current theme)
   set theMessage to theMessage & return & "The appearance prop is: " &¬
   (appearance of current theme)
end tell
(* use display dialog osax to display the values of these Appearance properties *)
display dialog theMessage

    Team LiB   Previous Section   Next Section