Applescript to fill in Keychain dialog box
Consider altering the requirement for a password. Printers on Mac OS X are managed by the Common UNIX Printing System (CUPS) and it is highly configurable.

Mac OS X Hints published this, Disable printer queue password requirements, for disabling printer queue passwords. It should work for modern versions of OS X:


  
  As root, or in a Terminal session with su privileges, edit /etc/cups/cupsd.conf.
  Find the section below.
  Remove the items you don't want limited: Pause-Printer, Resume-Printer, Pause-Printer-After-Current-Job, etc.
  Save the file, quit the editor, and restart your computer
  


Section to find and edit:

  &lt;Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Res
tart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Accept-Jobs CUPS-Reject-Jobs&gt;
      AuthType Default
      Require user @AUTHKEY(system.print.admin) @admin @lpadmin
      Order deny,allow
  &lt;/Limit&gt;