How to script the launching of a script at a specific time...

Jean-Christophe Helary
 

If there is an Applescript way to open a specific file at a given time that does not involve Calendar, I'm all for it, but right now I'm trying to focus on Calendar because that's where I manage all my jobs. So...

I know I can use Calendar's "open file alert" to open a file at a specific time. It works fine when I manually create an event.

What I want to do is to script the creation of that event, and for that I need to specify the filepath property of the "open file alert" but *that* doesn't work. I end up with an event that does *not* have a filepath and that won't open the file.

Conversely, when I manually create the alert, it does work *but* the event as explored in SD does not provide any value for the filepath property, so I have no way to see what I'm doing wrong.

Specifically:

tell application "Calendar"
activate
set job to make new event in calendar "test" with properties {allday event:true, status:confirmed, start date:(date "Saturday, December 2, 2017 0:00:00"), end date:(date "Sunday, December 3, 2017 0:00:00"), description:"Test", summary:"launch file", location:"Jean-Christophe", url:""}
set filealert to make new open file alarm of job with properties {filepath:"/path/to/file", trigger date:(date "Friday, December 1, 2017 16:26:00")}
switch view to week view
show job
end tell

Plus, that code *sometimes* triggers a Calendar error that goes like this:


I take any suggestions that solves that Calendar issue (most probably caused to my poor coding skills), or any solution that bypasses Calendar but stays reasonably within what Applescript allows :-)


Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com


Join applescript@apple-dev.groups.io to automatically receive all group messages.