【发布时间】:2016-02-08 23:35:30
【问题描述】:
我正在编写一些小程序来生成大量事件并将其添加到我的日历中,其中许多事件需要多个警报:上午 9 点的“默认”警报和存储在变量中的第二个警报。但是,当我运行它时,实际创建的警报是不一致的:有时我会收到一个警报,有时会收到另一个警报,有时会同时收到两个警报。
这是处理 100% 与日历和测试用例交互的子组件。
on makeCalendarEvent from {eventTitle, eventStart, eventDuration, eventDescription, eventURL, alarmTime, setDefaultAlarm}
--duration (in hours, 0= instantaneous, -1= all day)
--alarmTime (date or false)
--defaultAlarm 9AM (coded here for the moment, may move the parameter up to the var block at some point)
if eventDuration = -1 then
set isAllDay to true
set eventDuration to 0
else
set isAllDay to false
end if
tell application "Calendar"
tell calendar "test"
set newEvent to make new event at end with properties {summary:eventTitle, start date:eventStart, end date:(eventStart + (eventDuration * hours)), allday event:isAllDay, description:eventDescription, url:eventURL}
if alarmTime is not false then
tell newEvent
set alarm1 to make new sound alarm at end of sound alarms with properties {trigger date:alarmTime}
end tell
end if
if setDefaultAlarm is true then
tell newEvent
set alarm2 to make new sound alarm at end of sound alarms with properties {trigger date:(date "09:00 AM" of eventStart)}
end tell
end if
end tell
end tell
end makeCalendarEvent
makeCalendarEvent from {"New Moon", date ("Monday, February 8, 2016 at 09:39:00"), 0, "", "", date ("Monday, February 8, 2016 at 09:39:00"), true}
我不经常在 Applescript 中工作,所以完全有可能我只是搞砸了语法,但我已经尝试了所有方法,从替代语法到在“告诉事件”之间添加延迟再到使用一个作为声音警报和一个显示。在这一点上,我想知道我是否离它太近了,或者它是否是我将不得不忍受的那些怪癖之一,或者找到一个终点。
任何帮助将不胜感激。
【问题讨论】:
标签: macos calendar applescript osx-elcapitan