RE: Scripting the Chooser
RE: Scripting the Chooser
- Subject: RE: Scripting the Chooser
- From: Hellum Timothy <email@hidden>
- Date: Tue, 6 Feb 2001 15:37:50 -0500
Many thanks, Jean-Marie!
Although Canadian, my French is (plus regrettable) barely adequate.
However, I think I can puzzle through the syntax (verbal, that is!).
Actually, I was pleased to see an error pop up in French. I may just tuck
in some French in other scripts to see if my fellow Canadians are awake
during script runs! ha!
Timothy
Photodesk
The Globe and Mail
www.globeandmail.ca
(416) 585-5375
_______________________________
Once again the thought strikes me:
Half is quite a bit of wit.
~ Tom Waits
>
----------
>
From: Jean-Marie Hoornaert
>
Sent: Tuesday, February 6, 2001 3:21 PM
>
To: AppleScript-Users
>
Subject: Re: Scripting the Chooser
>
>
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
>
_______________________________________________
>
applescript-users mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/applescript-users