TOPIC
How can I use AppleScript to create a desktop printer?
DISCUSSION The syntax details for the Desktop Printer Manager can be shown from the Script Editor. Select Open Dictionary from the File Menu, click the go to "Scripting Additions" folder button and then open the item from the list called Desktop Printer Manager. Interpreting this information can take a bit of thought. A record of properties for the printer must be specified. The difficult item to construct is the address specification for address. Either of two syntax flavors can be used to specify the location of the Desktop Printer file: Make new desktop printer at alias "Macintosh HD:" ... - or - Make new desktop printer with properties {container: "Macintosh HD:"... } Other property items such as name (name given to DTP icon), and driver name (Chooser device name), should be supplied, while other items, such as PPD File (LaserWriter Printer description), can be specified if appropriate. The address property is a record of properties within the first property list and is needed to clarify how the printer is connected or accessed. Here are several examples showing how to define printers with different connection methods. Example 1 - a locally attached Color StyleWriter tell application "Desktop Printer Manager" make new desktop printer at alias "Macintosh HD:" with properties {name: "CSW 2500", driver name: "Color SW 2500", address:{protocol:serial, conduit: printer port}} end tell Example 2 - a network accessed Color StyleWriter tell application "Desktop Printer Manager" make new desktop printer at alias "Macintosh HD:" with properties {name: "CSW 2500 Net", driver name: "Color SW 2500", address:{protocol:AppleTalk, AppleTalk machine: "CSW Host", AppleTalk zone: "*", AppleTalk type: " Color SW 2500"}} end tell Example 3 - an AppleTalk LaserWriter tell application "Desktop Printer Manager" make new desktop printer at alias "Macintosh HD:" with properties { name: "LW", driver name: "LaserWriter 8", address:{protocol:AppleTalk, AppleTalk machine: "My LW", AppleTalk zone: "*", AppleTalk type: "LaserWriter"}} end tell Example 4 - an LPR LaserWriter tell application "Desktop Printer Manager" make new desktop printer at alias "Macintosh HD:" with properties { name: "LPR", driver name: "LaserWriter 8", PPD file: generic, address:{protocol:IP, ID:"17.100.100.100"}} end tell Example 5 - a SCSI LaserWriter (note: Apple's SCSI LaserWriters are unsupported under Mac OS 8) tell application "Desktop Printer Manager" make new desktop printer at alias "Macintosh HD:" with properties {name: "SCSI LW", driver name: "Some SCSI LW Driver", address:{protocol:SCSI, ID: 2}} end tell |
Document Information | |
Product Area: | Mac OS System Software |
Category: | Mac OS 8.5 |
Sub Category: | Printing |
Copyright © 2000 Apple Computer, Inc. All rights reserved.