i am trying to make an applescripts to add a printer and delete a printer when a user logs in and logs out
so i think im heading in the correct direction for the first script to add a printer, but i hit a roadblock
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.printfax"
end tell
tell application "AddPrinter"
activate
is all i have so far because i cant figure out how to get the printer selected.
Its just a usb printer and all the drivers are installed.
i can see the list to choose the printer, but cant figure out how to select it.
any tips would be helpful
thanks
Here’s an example by StefanK for choosing a printer:
set thePrinters to choosePrinters()
if thePrinters is false then return
display dialog "enable or disable printer(s)" buttons {"Cancel", "Enable", "Disable"}
if button returned of the result is "Enable" then
set command to "enable"
set statusCheck to "is not ready"
else
set command to "disable"
set statusCheck to "is ready"
end if
repeat with onePrinter in thePrinters
if (do shell script "/usr/bin/lpq -P " & onePrinter) contains statusCheck then
do shell script "/usr/bin/" & command & space & onePrinter
end if
end repeat
on choosePrinters()
set printerList to paragraphs of (do shell script "/usr/bin/lpstat -a | /usr/bin/awk '{print $1}'")
tell current application
return (choose from list printerList with prompt "Please choose a printer" with multiple selections allowed)
end tell
end choosePrinters