Creating a windows printer

Hi,

I’ve spent a long time trying to get the script working but I just can’t seem to be able to get it working.

What I’m trying to do is create an automatic script to add a windows printer that can be accessed on all of the macs at a lab.

My problem is that the final “Add” command is not working. When it is clicked it doesn’t do anything. If I add the printer manually without the script, however, I can click the “Add” button successfully.

Another thing I wanted to do was make the “keystroke” commands into actually “click button” commands but I can’t figure out how to do that.

Here is the script that I have so far –


tell application “AddPrinter” to activate
tell application “System Events” to tell process “AddPrinter”
tell tool bar 1
tell menu 1
tell menu item “Customize Toolbar.”
end tell
end tell
end tell
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
– searching for printers may well take several seconds
end repeat
click pop up button 1
click menu item “Windows printer via spoolss” of menu 1 of pop up button 1
delay 2
set value of text field 1 to “smb://bju-printers/FA_Lab_17_MFP”
delay 1
end tell
tell group 1
set value of text field 1 to “FA_Lab_17_MFP”
click pop up button 1
click menu item “Select Printer Software.” of menu 1 of pop up button 1
delay 2
set uiScript to keystroke “SHARP DX-C401 PPD”
key code 48
key code 125
delay 2
key code 36
end tell
end tell
delay 2
click button “Add” of window “Add Printer”
delay 3
key code 36
end tell
–tell application “AddPrinter” to quit

Thanks!