UI Scripting --> Printer Setup Utility

Hi everyone,

I am doing a project for work in which here on the campus it will automatically set up and add the university’s printer server to the Apple computer that it is on. So far I have only up to the point where it opens the Printer Setup Utility, and that’s about it.

What I need it to do next:

  • Click Add
  • While holding OPTION click “More Printers…”
  • Select “Advanced” under the drop down menu that pops up
  • Choose a particular option (SAMBA)
  • Enter info in the Device Name / Device URL by itself
  • Click Add

My problem is that I dont know how to get it to click the “More Printers…” part while holding the option key down. Does anyone know how to do this, or help me get started? I’m using a MacBook with Tiger.

Hi,

maybe you can do this without GUI scripting.
Look at this thread

While that definitely is close to what I"m looking for, I don’t know exactly what I need to modify or what I need to add for the scripts on that page to do what >>I<< need it to do… such as holding down Option while clicking Add Printer… changing the selection in the drop down menu box, etc etc…

Also, I need it to ask the user for the username and password for entering into this form as well…and then the program needs to input it into the form.

can anyone help me in adapting the code to do what I need?

Hi,

I don’t use a SMB network, so I cannot test anything.
I found this line at macosxhints for the do shell script line.

sudo lpadmin -p 1055CMBond -v smb://$username:$password@$domain/$servername/hp1055cmbond -P '/Library/Printers/PPDs/Contents/Resources/en.lproj/HP DesignJet 1055CM PS3.gz' -E

-p is the name of the printer (1055CMBond)
-v is the URL of the printer, if you omit $username and $password, the user will be prompted
-P is the location of the PPD file
-E enables and activates the printer

Add a printer manually and take URL and PPD path from the info window.
If the SMB-path contains a space character, it also must be quoted

How can I set the Generic.PPD?

EDIT: It responds with “Printer name can only contain printable characters!”… continues to work anyway in terms of asking for my password to add, and adds it as a ‘Local Raw Printer’… I chose one of the random Laserjet.gz’s in the Library PPDs folder because I couldn’t find the Generic.ppd file… and the printer’s status is set to stopped instead of active… and it didn’t ask me for a user name / password …

the generic PPD is used in the script in the thread mentioned above.
I don’t know why, but lpadmin doesn’t like space characters in the name. Use underline characters instead

/Library/Printers/PPDs/Contents/Resources/en.lproj/HP DesignJet 1055CM PS3.gz’ is the generic? should it be /System/Library or is /Library fine?

No, I mean this script

property IPaddress : "192.168.70.2"
property Queue : "studentprinter"
property printername : "Fuller_Library_Printer"
property printerlocation : "Library Print System"

do shell script "lpadmin -p '" & printername & "' -v " & quoted form of ("lpd://" & IPaddress & "/" & Queue) & " -P /usr/share/cups/model/generic.ppd -o printer-is-shared=false -L " & quoted form of printerlocation & " -E"
tell application "System Preferences"
   activate
   reveal anchor "print" of pane id "com.apple.preference.printfax"
end tell

I used the /usr/share/cups/model/generic.ppd, and it now says:

lpadmin: add-printer (set model) failed: client-error-not-found

I dont see this generic.ppd anywhere… I am using Tiger.

I know exactly what I need to click / type if maybe the GUI scripting way is easier…

what I am typing into bash:

sudo lpadmin -p test -v smb://@ucmerced/ucprint/ucmglobal -P /usr/share/cups/model/generic.ppd -E

Sorry, I’m using Leopard, and UI scripting can only be puzzled reliably on the target operating system

Oh ok. Well is the above lpadmin…blah blah blah for leopard then? Or coudl you help me with the GUI SCripting for Leopard? We are planning on doing this for both Tiger and Leopard systems.

lpadmin works also in Tiger, maybe the cups PPD’s are located somewhere else
GUI scripting for adding printers in completely different in Tiger and Leopard, because Printer Utility.app in Leopard has been discontinued

Oh ok. Could you help me with just the Leopard part then?

I’d like to, but as mentioned before, I haven’t any SMB network, and therefore I don’t see any SMB item to choose

I googled this:
http://www.macosxhints.com/article.php?story=20071026060126378

hopefully that helps?

Let me say it again:
Developing an AppleScript is much of trial&error.
Without having the desired network connection or having a certain device you can’t do it because you are not able to test it.

Ok. I will try and get a leopard machine from the labs to test. Will get back to you later.