I developed a script for use with osasubr to pass arguements to a applescript.
My script takes a printer name and webpage url and prints that page with no user interaction (background script) in safari
I get a unhandled applescript event on my script using osasubr (it says to check if subroutine exists, but it does)
No matter what I do I can’t figure out what is causing the error.
The only good news is that if you setup the variables statically the script runs fine, but of course in order for the script to be useful/flexible I need it to take agruements
Any ideas or advice?
Thanks
Mike
on run {webpage, newprinter}
tell application "System Events" to set web_running to exists process "Safari"
tell application "Printer Setup Utility"
activate
tell application "System Events" to set visible of process "Printer Setup Utility" to false
set oldprinter to current printer
set current printer to printer newprinter
end tell
tell application "Safari"
activate
if web_running then
set oldwebpage to (URL of document 0)
else
tell application "System Events" to set visible of process "Safari" to false
end if
set (URL of document 0) to webpage
delay 2
print document 0 without dialog and interaction
if web_running then
set (URL of document 0) to oldwebpage
else
quit
end if
end tell
tell application "Printer Setup Utility"
set current printer to oldprinter
quit
end tell
end run