DekGenius.com
Team LiB   Previous Section   Next Section
Application Switcher

Syntax

tell app "Application Switcher"
   set palette's orientation to vertical -- programs are displayed top to bottom
end tell

Dictionary commands

run

This launches the application if it isn't running and is the same as double-clicking its icon.

quit

This command quits Application Switcher, releasing its memory resources.

Dictionary classes

application

This class represents the Application Switcher application. It has the following five properties, which can be accessed simply by referring to them within a:

tell app "Application Switcher"

block, as in:

tell app "Application Switcher" to set palette's button ordering to¬ alphabetical

palette (window object)

This property returns as a window object the palette that displays all the running programs. You can then alter the palette's properties, as in:

set palette's position to upper left

For example, you can show only the program icons in the palette (so that it does not take up very much room on the screen) with the following code:

tell app "Application Switcher" to set palette's names visible¬ to false
keyboard cycling active (boolean)

This is a true/false value indicating whether you can use the keyboard combination, Command-Tab or otherwise, to switch from one open program to another. See "cycling keystroke" for how to set your own keyboard combination for this cycling behavior.

cycling keystroke (keystroke object)

You can set the keyboard combination for cycling through open programs (each program will become the highlighted program on the desktop in sequence as you press this key combo). This example changes this cycling keystroke to Control-F1:

tell application "Application Switcher"
set stroke to {key:F1 key, modifiers:{control down}}
set cycling keystroke to stroke
end tell

The keystroke object takes the form of a record type, a series of property/value pairs separated by commas and contained within curly braces ({ }). You can set its key property to either a string (e.g., "p") or a constant like tab key, up arrow key, or F1 key. Its modifiers property is also set to a constant such as control down. So the value of the cycling keystroke property can be set to a record such as the following:

{key:F1 key, modifiers:{control down}}

quit delay (constants default/never or integer)

Accessing this property will return the constants default, never, or an integer representing the number of seconds, approximately, of delay before the application quits. By changing this property, I did not see any change in the Switcher's behavior when it was quit or its window was hidden. Anyway, even if you quit Application Switcher, say by using its quit command, you can quickly reproduce the palette by dragging with the mouse from the upper corner.

credits (string)

This is a self-congratulatory message from the Application Switcher programmers.

keystroke

The keystroke object is returned by the Application Switcher's cycling keystroke property (see its description in this chapter). This class has key and modifiers properties.

key (string or constant)

This property can be set to either an alphanumeric keyboard character such as "h" or one of the following constants:

clear key
F8 key
delete key
F9 key
down arrow key
forward del key
end key
help key
enter key
home key
escape key
left arrow key
F1 key
page down key
F2 key
page up key
F3 key
return key
F4 key
right arrow key
F5 key
tab key
F6 key
up arrow key
F7 key

See the next example and the "cycling keystroke" description for more details.

modifiers (list of constants)

modifiers can be a list of any of the following constants: option down/command down/control down/caps lock down. If you want to cycle through your open apps with the F1 key pressed together with the control key, the value of the keystroke object is:

{key:F1 key, modifiers:{control down}}
window

This class represents the Switcher's floating palette. The application class' palette property returns a window object; you can then control its display and behavior with the following properties.

properties (record)

The value of this record type is all of the open palette's properties. Here's an example:

{position:{943, 288}, bounds:{943, 288, 1039, 432}, anchor 
point:upper left, button ordering:launch order, constraint:none, 
frame visible:true, icon size:small, name width:72, names visible:true, 
orientation:vertical, visible:true}

You can create a custom Switcher palette by setting the application's palette to your own record value, as in the following (add a record value like the preceding example):

tell app "Application Switcher" to set palette's properties to ...
visible (boolean)

A true/false value determining whether the palette is visible.

orientation (horizontal/vertical)

The palette in Figure 22-1, for example, is in the vertical orientation.

position (point object or constants upper left/upper right/lower left/ lower right.)

You can set the palette position with one of the four constants (e.g., upper right) or a point in the top left corner of the window, as in:

set palette's position to {50, 150}

This code moves the palette to the position 50 pixels from the left border of the screen and 150 pixels down.

bounds (bounding rectangle)

You can also establish the palette's position as a list of four coordinates, such as {943, 288, 1039, 432}. See the Examples section at the end of this chapter.

anchor point (constants upper left or lower right)

Get or set the anchor point of the palette to either of the two constants. This prop does not affect the way a vertical palette can be dragged in size, however. You can only drag the window horizontally to the point where the longest program name is fully displayed.

button ordering (constant)

This property can be set to one of the following constants: alphabetical/launch order/reverse alphabetical/reverse launch order.

constraint (constants none, all monitors, or one monitor)

You can display the palette on one or more monitors connected to the computer.

frame visible (boolean)

You can remove the title bar of the Application Switcher's palette with a phrase such as:

set  palette's frame visible to false

The palette can still be moved around the screen by Command-clicking it.

icon size (small or large)

Use this property to control the size of icons in the palette.

names visible (boolean)

This property is a true/false value that determines whether the palette will display only icons or icons and program names.

name width (integer)

Set the amount of space that Switcher devotes to the program names to the pixel width of your choice. If it cannot fit in the palette, the program name will be truncated with an ellipses (...) added to the end of it.

Example

(* This script sets the bounds of Switcher based on the bounds of a Word 
window *)

(* Find out how many programs are running that are displayed in Switcher 
so that we can set the height of the palette; 24 pixels per program including 
the Finder. The script uses the Finder's application processes property, then 
does not count the background processes that do not display in the Switcher *)

tell application "Finder"
   set noDisplay to 
   {"Control Strip Extension", "DAVE Sharing Extension",¬
   "HP Background", "Time Synchronizer", "File Sharing Extension",¬
   "ShareWay IP Personal Bgnd", "Application Switcher",¬
   "Time  Synchronizer"}
   set procs to application processes -- list of running processes
   set counter to 0 -- count of processes that are displayed
   repeat with p in procs
      set n to (name of p) -- name of app like "Script Editor"
      (* count the app if it is not in the list of programs that don't display 
in Switcher *)
      if noDisplay does not contain n then set counter to counter + 1
   end repeat
end tell
set counter to counter + 1 (* include the Finder in apps that are displayed 
in Switcher *)
tell application "Microsoft Word"
   activate
   (* Get the bounds of this window *)
   set wdbounds to bounds of window 1
end tell
tell application "Application Switcher"
   (* set X coordinate of palette's upper left corner to 5 pixels to the right 
of the Word window.  If Word window bounds are {52, 99, 983, 720} then item 3 
of the bounds is 983 *)
   set rightpoint to (item 3 of wdbounds) + 5
   (* we want the palette height to be the number of displayed apps times 24 
pixels *)
   set height to counter * 24
   (* set palette bounds to 5 pixels to the right of Word win, one and a half 
inches from the top of the screen (about 108 pixels), a width of 127 pixels, 
and a height of 108 plus (the number of programs * 24 pixels). The Switcher 
will dynamically accommodate all the displayed programs in the palette height 
anyway *)
   set palette's bounds to {rightpoint, 108, (rightpoint + 127), (108 +¬
   height)}
   log palette's bounds -- check out the new bounds in Event Log window
end tell
    Team LiB   Previous Section   Next Section