Avoiding AppleEvent Timed Out Error -1712
Hey all I am relatively new to applescsripting. I have come up with the below applescript for a project here at work. Basically this applescript is used to open pdfs in full screen mode, display them for set lenght of time and rotate continously. It is intended for this script to never stop unless the machine is rebooted. Every 30 minutes or so, the script closes the pdf windows and goes out to a share drive to get updated copies, that it then copies to local drive, replacing the ones there already.
My question or problem is thus, I have been getting Appleevent Timed out Errors and would like to know the best way to avoid or deal with these and have script to either start over or continue executing but not just stop dead in its tracks. The last line I got an AppleEvent Timed out error on was
execute menu item "FullScreenMode"
but i have received it elsewhere in the script also.
Any thoughts or suggestions would be appreciated.
set intcount to 0
tell application "Adobe Acrobat Pro"
execute menu item "FullScreenMode"
repeat
try
tell application "Finder"
set intcount to intcount + 1
set source to "Operations:Production_Schedule_pdf:PSchedule.pdf"
set source2 to "Production:Maintenance Planner (C.Slasor):Presentations_pdf:DowntimeData.pdf"
set source3 to "Production:Maintenance Planner (C.Slasor):Presentations_pdf:MaintSchedule.pdf"
set home_path to home as text
set destination to home_path & "Documents:"
if intcount = 15 then
duplicate file source to folder destination with replacing
duplicate file source2 to folder destination with replacing
duplicate file source3 to folder destination with replacing
set intcount to 1
end if
end tell
on error
rotateLocally()
end try
tell application "Adobe Acrobat Pro"
open ("/Users/drivord/Documents/PSchedule.pdf")
if intcount = 1 then
execute menu item "FullScreenMode"
end if
delay 60
if intcount = 14 then
close front document
end if
open ("/Users/drivord/Documents/MaintSchedule.pdf")
delay 30
if intcount = 14 then
close front document
end if
open ("/Users/drivord/Documents/DowntimeData.pdf")
delay 30
if intcount = 14 then
close front document
end if
end tell
end repeat
end tell
(*
on error the error_message number the error_number from the offending_object
if the error_number is equal to 128 then
close front window
tell application "Adobe Acrobat Pro"
execute menu item "FullScreenMode"
repeat
open ("/Users/drivord/Documents/PSchedule.pdf")
delay 60
open ("/Users/drivord/Documents/MaintSchedule.pdf")
delay 30
open ("/Users/drivord/Documents/DowntimeData.pdf")
delay 30
end repeat
end tell
else
-- An unknown error occurred. Resignal, so the caller
-- can handle it, or AppleScript can display the number.
set the error_text to "Error: " & the error_number & ". " & the error_message
-- the following line evokes the sub-routine to write the error into an error log created on the desktop
-- if the file "Script Error Log.txt" already exists, it will add one line to the log
my write_error_log(the error_text)
my send_error_email(the error_text)
end if
*)
on rotateLocally()
close front window
tell application "Adobe Acrobat Pro"
execute menu item "FullScreenMode"
repeat
open ("/Users/drivord/Documents/PSchedule.pdf")
delay 60
open ("/Users/drivord/Documents/MaintSchedule.pdf")
delay 30
open ("/Users/drivord/Documents/DowntimeData.pdf")
delay 30
end repeat
end tell
end rotateLocally
on write_error_log(this_error)
set the error_log to ((path to desktop) as text) & "MAC015 Error Log.txt"
try
open for access file the error_log with write permission
write (this_error & return) to file the error_log starting at eof
close access file the error_log
on error
try
close access file the error_log
end try
end try
end write_error_log
on send_error_email(this_error)
set the_subject to "mac15 Monitor error"
set the_body to this_error
(* send email using Mail
tell application "Mail"
tell new_message
--add recipients
make new to recipient at end with properties ¬
{name:"Ken", address:"kscott@sabra.com"}
make new cc recipient at end with properties ¬
{name:"Doug", address:"drivord@sabra.com"}
send
end tell
end tell
*)
tell application "Microsoft Outlook"
set OutgoingEmail to make new outgoing message with properties {subject:the_subject, content:this_error}
make new recipient at OutgoingEmail with properties {email address:{name:"Ken", address:"kscott@sabra.com"}}
make new cc recipient at OutgoingEmail with properties {email address:{name:"Doug", address:"drivord@sabra.com"}}
send message id (id of OutgoingEmail)
end tell
end send_error_email
OS X Mountain Lion (10.8.3)