AppleScript名:プリンタ一覧を取得してデフォルトに設定 |
— Created 2015-08-11 by Shane Stanley use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "AppKit" set theNames to current application’s NSPrinter’s printerNames() as list –> {"KING JIM TEPRA PRO SR3700P", "NEC MultiWriter 5750C @ MBA13", "PDFwriter", "PM-T960-1", "USB Modem"} set printerName to (choose from list theNames with prompt "Choose a printer:") if printerName = false then error number -128 set thePrinter to current application’s NSPrinter’s printerWithName:(item 1 of printerName) (* –> (NSPrinter) { "Device Description" = { NSDeviceIsPrinter = YES; }; "Language Level" = 3; Name = "NEC MultiWriter 5750C @ MBA13"; Type = "NEC MultiWriter 5750C v2.4"; } *) set thePrintInfo to current application’s NSPrintInfo’s sharedPrintInfo() (* –> (NSPrintInfo) { NSBottomMargin = 90; NSCopies = 1; NSDestinationFormat = "com.apple.documentformat.default"; NSDetailedErrorReporting = 0; NSFaxNumber = ""; NSFirstPage = 1; NSHorizonalPagination = 2; NSHorizontallyCentered = 1; NSJobDisposition = NSPrintSpoolJob; NSJobSavingFileNameExtensionHidden = 0; NSLastPage = 2147483647; NSLeftMargin = 72; NSMustCollate = 1; NSOrientation = 0; NSPagesAcross = 1; NSPagesDown = 1; NSPaperName = "iso-a4"; NSPaperSize = "NSSize: {595, 842}"; NSPrintAllPages = 1; NSPrintProtected = 0; NSPrintSelectionOnly = 0; NSPrintTime = "0000-12-30 00:00:00 +0000"; NSPrinter = "{\n \"Device Description\" = {\n NSDeviceIsPrinter = YES;\n };\n \"Language Level\" = 3;\n Name = \"NEC MultiWriter 5750C @ MBA13\";\n Type = \"NEC MultiWriter 5750C v2.4\";\n}"; NSPrinterName = "NEC MultiWriter 5750C @ MBA13"; NSRightMargin = 72; NSSavePath = ""; NSScalingFactor = 1; NSTopMargin = 90; NSVerticalPagination = 0; NSVerticallyCentered = 1; } *) thePrintInfo’s setPrinter:thePrinter |
More from my site
(Visited 129 times, 1 visits today)