GUI Help

Hi, i have this script which adds new printer through Add printer app, but is there any way to hide the process so that the user cannot see it. All i need is to hide the GUI of the script opening add printer…and doing its thing…

Thanks

This is what needs to be hidden…


tell application "AddPrinter" to activate
tell application "System Events" to tell process "AddPrinter"
	click button "Advanced" of tool bar 1 of window "Add Printer"
	tell group 1 of window "Add Printer"
		tell group 2
			repeat until pop up button 1 exists
			end repeat
			click pop up button 1
			click menu item "Windows" of menu 1 of pop up button 1
			set value of attribute "AXFocused" of text field 1 to true
			set value of text field 1 to "smb://print server"
		end tell
		tell group 1
			set value of text field 1 to "Printer name"
			set value of text field 2 to "printer location"
			click pop up button 1
			click menu item "Generic PostScript Printer" of menu 1 of pop up button 1
		end tell
	end tell
	click button "Add" of window "Add Printer"
end tell


Hi,

GUI scripting without GUI is not possible.
But maybe you could perform the task with the shell lpadmin command

Very frequently, I script Safari’s user interface. I have noticed that the GUI script works fine even if Safari is not frontmost (i am not saying “hidden”) i.e.it clicks at appropriate places in the web page. So if the frontmost application I use, occupies my entire screen then Safari is as good as hidden and the script runs properly while I am working in my front most application. I am not sure about GUI scripting in other applications.

Hi,
I used the lpadmin command and this what i understood

sudo lpadmin -E -p “PrinterName” -v “smb://username:password@servername” -P /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/Resources/Generic.ppd

This does add the printer but as soon as I try to print the printer says “Error While Printing”

The printer I am trying to connect to is a smb printer (type windows), and uses the Generic postcript printer…can you help me figure this out please… not that well accustomed to terminal…

Thanks

I’m not very familiar with lpadmin, but maybe this helps
http://www.google.com/search?q=lpadmin+smb+mac&ie=utf-8&oe=utf-8

Hi,
Here is the script i made using the lpadmin command, the terminal command works perfectly, but it adds the printer as “paused” is there any way to make sure that the printer queue is resumed after adding the printer

Thanks,


set tuser to the text returned of (display dialog "Enter your ID:" default answer "For Example: jdoe")
set tpass to the text returned of (display dialog "Enter your Password:" default answer "" with hidden answer)

do shell script "lpadmin -p printerName -v smb://" & tuser & ":" & tpass & "@printserver -P /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/Resources/Generic.ppd"
do shell script "accept printerName"