Re: Scripting the Chooser
Re: Scripting the Chooser
- Subject: Re: Scripting the Chooser
- From: Jean-Marie Hoornaert <email@hidden>
- Date: Tue, 06 Feb 2001 21:21:16 +0100
le 5/02/01 23:17, Hellum Timothy a icrit :
>
Hello,
>
>
Does anyone know how to script the Chooser? In the absence of a
>
dictionary, I find myself at loose ends. I am very much a beginner.
I have write a script who list desktop printer and others.
He use the "Set Printer to" OSAX and the "Desktop Printer Manager" who is
also in the "Scripting additions" folder.
Sorry for my "bad" english but i'm french speaking.
So, the "display dialog" ad the end of the script is still in french.
Thank's to Apple : AppleScript is easy english langage ;)
[script]
try
set default_printer to ""
set chemin_extensions to (path to the extensions)
tell application "Finder"
set chooser_printer_list to the name of ,
(every file of chemin_extensions whose ,
file type is in {"PRER", "PRES"}) as list
end tell
tell application "Desktop Printer Manager"
set the driver_list to the driver name of every desktop printer
set the desktop_printer_list to the name of every desktop printer
try
set the default_printer to the name of the default printer
end try
end tell
set printer_list to {}
repeat with i in chooser_printer_list
if not (driver_list contains i) then
set printer_list to (printer_list & i) as list
end if
end repeat
set printer_list to (printer_list & desktop_printer_list) as list
set message_ to "Choose a printer"
if default_printer is not "" then
set message_ to message_ & return & ,
"Current printer : " & default_printer
end if
set DTP_name to choose from list printer_list ,
with prompt message_ without multiple selections allowed
if DTP_name is not false then
if desktop_printer_list contains DTP_name then
tell application "Desktop Printer Manager"
set the default printer to ,
desktop printer (item 1 of DTP_name)
end tell
else
(set printer to DTP_name) -- OSAX "set printer to"
end if
end if
tell me to quit -- if save as applet
on error error_text number error_number
display dialog "Une erreur s'est produite." & return & ,
"Erreur : " & error_text & " numiro " & error_number & ,
"Virifiez que les compliments de pilotage \"Set printer to\" " & ,
"sont prisents. " buttons {"OK"} default button 1 with icon caution
end try
tell me to quit -- if save as applet
[/script]
PS : this is my first message on this list.
--
Jean-Marie -HOO;-)
____________________
Jean-Marie Hoornaert
Courriel : email@hidden
PPsP* :
http://www.h2o.be
* Page Personnelle sans Pritention
* pour AppleScripter FileMaker