带有日历和 Applescript 的多个事件警报?
Multiple Event Alarms with Calendar and Applescript?
我正在开发一些 applescript 来生成大量事件并将其添加到我的日历中,其中许多事件需要多个警报:上午 9 点的 "default" 警报和存储时间的第二个警报在一个变量中。然而,当我 运行 它实际创建的警报是不一致的:有时我收到一个警报,有时是另一个,有时是两个。
这是处理 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,所以我完全有可能把语法搞砸了,但我已经尝试了从替代语法到在 "tell events" 之间添加延迟的所有方法使用一个作为声音报警器和一个作为显示。在这一点上,我想知道我是否离它太近了,或者它是否是我将不得不忍受的怪癖之一,或者找到一个结束-运行。
如有任何帮助,我们将不胜感激。
我已经多次测试了您的脚本,没有任何问题。我收到了 2 个警报。我只是做了一些更改来优化脚本本身,但它不会改变您的逻辑。当然,我没有玩所有参数,但即使 2 个警报非常关闭(上次测试是 8:00 和 8:05am),我仍然会收到 2 个警报!
makeCalendarEvent from {"New Moon", date ("09/02/2016 08:05:00"), 0, "", "", date ("09/02/2016 08:05:00"), true}
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)
set isAllDay to (eventDuration = -1)
if eventDuration = -1 then set eventDuration to 0
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}
tell newEvent
if alarmTime is not false then set alarm1 to make new sound alarm at end of sound alarms with properties {trigger date:alarmTime}
if setDefaultAlarm is true then set alarm2 to make new sound alarm at end of sound alarms with properties {trigger date:(date "08:00 AM" of eventStart)}
end tell
end tell
end tell
end makeCalendarEvent
我正在开发一些 applescript 来生成大量事件并将其添加到我的日历中,其中许多事件需要多个警报:上午 9 点的 "default" 警报和存储时间的第二个警报在一个变量中。然而,当我 运行 它实际创建的警报是不一致的:有时我收到一个警报,有时是另一个,有时是两个。
这是处理 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,所以我完全有可能把语法搞砸了,但我已经尝试了从替代语法到在 "tell events" 之间添加延迟的所有方法使用一个作为声音报警器和一个作为显示。在这一点上,我想知道我是否离它太近了,或者它是否是我将不得不忍受的怪癖之一,或者找到一个结束-运行。
如有任何帮助,我们将不胜感激。
我已经多次测试了您的脚本,没有任何问题。我收到了 2 个警报。我只是做了一些更改来优化脚本本身,但它不会改变您的逻辑。当然,我没有玩所有参数,但即使 2 个警报非常关闭(上次测试是 8:00 和 8:05am),我仍然会收到 2 个警报!
makeCalendarEvent from {"New Moon", date ("09/02/2016 08:05:00"), 0, "", "", date ("09/02/2016 08:05:00"), true}
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)
set isAllDay to (eventDuration = -1)
if eventDuration = -1 then set eventDuration to 0
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}
tell newEvent
if alarmTime is not false then set alarm1 to make new sound alarm at end of sound alarms with properties {trigger date:alarmTime}
if setDefaultAlarm is true then set alarm2 to make new sound alarm at end of sound alarms with properties {trigger date:(date "08:00 AM" of eventStart)}
end tell
end tell
end tell
end makeCalendarEvent