Player
Documentation
AppleScript
User's Guide
Chapter 6, Other Terms
Misc. Constants, Modifier Keys, Special Keys, Properties
In addition to verbs, Player defines many "nouns" or constants. (A constant is sort of like a variable that doesn't vary, i.e. whose value remains fixed rather than changing or being changed by a script.)Player's constants can be divided up into 4 categories:
- Misc. Constants
- Modifier Keys
- Special Keys
- PropertiesEach category is described on a separate page for easy reference.
Misc. Constants
Use the screen coordinates constant (new in 1.03) to treat coordinates as an absolute screen position.
To make it easy to set the mouse or typing delay back to the default, Player includes the default mouse delay and default typing delay constants (new in 1.1).
For the new disableUserInput verb, Player 1.5 includes mouse and keyboard constants.
Examples
click location {10, 20, screen coordinates} -- absolute position drag from {30, -10} to {31, 28, screen coordinates} } -- drag window to the upper left corner of the screen drag through { {40, -10}, {50, 50, screen coordinates} } -- drag window to an absolute screen position set mouse delay to default mouse delay -- reset (new in 1.1) set typing delay to default typing delay -- reset (new in 1.1) disable user input from keyboard -- allow mouse activity (new in 1.5) ... enable user input -- back to normalNotes
- Constant names are not case sensitive: AppleScript will convert them to lower case when it checks the syntax.
Modifier Keys
"Modifier keys are those that alter the way other keystrokes are interpreted. These keys sometimes affect the way the mouse-button actions are interpreted as well. They are the Shift, Caps Lock, Option, Command, and Control keys." Macintosh Human Interface Guidelines, p. 278
One or more modifier keys can be held down while performing some other action on the Macintosh. Player adds an optional holding parameter to most verbs.
Examples
type "a" holding command -- command-A, often for Select All type "3" holding command & shift -- screen shot type right arrow holding option -- move to end of word (in some apps) do menu menu item "Print" of menu "File" holding option -- send a FAX click location {1,1} holding shift -- select to the corner of the windowNotes
- Use "&" to "hold down" multiple keys simultaneously. (In contrast, when "&" is applied to standard keys, it means to type them one after another.)
- Modifier names are not case sensitive: AppleScript will convert them to lower case when it checks the syntax.
Special Keys
Many useful keys on the Macintosh keyboard have no real text equivalent. Player lets you specify these keys by name.
List of Supported Keys
- standard
- space, tab, return, enter, escape, delete
- arrows
- left arrow, right arrow, up arrow, down arrow
- misc.
- help, forward delete, home key, end key, page up key, page down key
- function
- F1 ... F15
- keypad
- keypad plus, keypad minus, keypad times, keypad divide, keypad equals, keypad decimal, keypad0 ... keypad9
Examples
type delete type up arrow holding command type {F1, page up key, down arrow, down arrow} -- any number of keys type {"byt", delete, "e"} -- mix keys and textNotes
- The numbers on the keypad are actually different keystrokes than the numbers across the top of a keyboard. Nevertheless, most applications interpret them the same way.
- "end key" has "key" as a suffix to avoid conflict with the built-in AppleScript term; the related keys end with "key" to be consistent parallel (home key, page up key, page down key)
- When typing just text or just keys, or beginning a sequence with a key (not with text), the items can by concatenated with "&" instead of using a list:
type "Hello" & "World" type left arrow & down arrow type F1 & "any text" -- AppleScript does not allow "any text" & F1- To type special characters that are not on the keyboard, use type and the ASCII character scripting addition that comes with AppleScript, e.g. type ASCII character 29 will enter the "Record Separator" character. (However, character 31 is reserved by Player and cannot be typed.)
- Key names are not case sensitive: AppleScript will convert them to lower case when it checks the syntax.
Properties
Player's query verbs provide useful information about an object. Many properties are common to all objects, others are specific to certain kinds. Because these properties pertain to objects in other applications, they are all "read-only" and their values cannot be changed.
List of Properties
Dialog and window items share 5 basic properties: kind, location, height, width, bounds. Each kind has the following additional properties.
- Button
- name, visible, enabled
- Radio Button
- name, visible, enabled, value
- Checkbox
- name, visible, enabled, value
- Pop-up Menu
- name, visible, enabled
- Scroll Bar
- name, visible, enabled, value, minimum, maximum
- Custom Control
- name, visible, enabled, value, minimum, maximum
- Text Entry Box
- item text
- Static Text
- item text
- Icon
- [just the 5 basic]
- Picture
- [just the 5 basic]
- User Item
- [just the 5 basic]
Menus have fewer properties:
- Menu
- name, kind, enabled, quantity
- Submenu
- name, kind, enabled, quantity
- Menu Item
- name, kind, enabled, checked, mark
Independent of kind, windows or dialogs have the following properties:
- any
- name, kind, active, visible, location, height, width, bounds
Examples
kind of (get info dialog item 14) checked of (get info menu item "Geneva" of menu "Font") height of (get info window "Untitled")Notes
- A "User Item" in a dialog or window could be almost anything, from a pop-up to a scrollable list to a simple graphic line.
- A "Static Text" dialog item is often used to identify for the user an item such as a text entry box that does not actually have an internal name.
- The window kind is a number that represents the window type according to the Macintosh Toolbox, as documented in Inside Macintosh. Unfortunately, there is enough variation in the way that windows are implemented that the number is not very useful to script writers. Some numbers you might encounter: 2 for a standard dialog or alert, 8 for a typical custom dialog, and negative numbers for a Desk Accessory.
- Property names are not case sensitive: AppleScript will convert them to lower case when it checks the syntax.
Property Descriptions
active: whether or not a window is active (frontmost)
bounds: rectangle coordinates (top, left, bottom, right)
checked: whether or not a menu item is checked
enabled: whether or not an item is enabled
height: height in pixels
item text: text contents
kind: the kind of item
location: XY coordinates of upper left corner
mark: the kind of mark on a menu item
maximum: maximum value (for a control)
minimum: minimum value (for a control)
name: item name
quantity: number of items
value: item value
visible: whether or not item is visible
width: width in pixels
Appendix 1, Questions & Answers
Copyright 1993-99, PreFab Software, Inc. All Rights Reserved.
This site built and maintained using Stage Three, a set of custom Frontier scripts.