Applescript создать событие в календаре, как мне удалить оповещение по умолчанию?
Запустив 10.8 Mountain Lion, я пытаюсь создать новое событие с помощью Applescript следующим образом:
set theDate to (current date)
tell application "Calendar"
tell calendar "Calendar"
set timeString to time string of theDate
set newEvent to make new event at end with properties {description:"Last Backup", summary:"Last Backup " & timeString, location:"To a local unix system", start date:theDate, end date:theDate + 15 * minutes, allday event:false, status:confirmed}
tell newEvent
delete every display alarm
delete every sound alarm
delete every mail alarm
delete every open file alarm
end tell
end tell
end tell
Однако это не удаляет предупреждение календаря по умолчанию, которое можно установить с помощью настроек календаря (в моем случае 30 минут назад).
Как создать событие без каких-либо сигналов тревоги через Applescript?
1 ответ
Похоже, еще один случай, когда AppleScript получает лечение нежелательного пасынка. Я предлагаю подать ошибку с Apple.
В частности, ошибочное поведение выглядит следующим образом, начиная с OS X 10.8.2:
-- Trying to set ANY properties on the *default* sound alarm fails silently.
-- Programmatically added alarms: only the trigger interval or date can be set.
repeat with al in every sound alarm of newEvent
tell al
-- Works only on *programmatically added* sound alarms:
set trigger interval to -770 # The alternative option, `set trigger date to ...`, works as well.
-- Fails silently on *all* sound alarms, whether it is the default one or a programmatically created one.
set sound name to "Pop" # `set sound file to ...` fails equally.
end tell
end repeat
-- This only deletes the programmatically added alarms, but never the default one.
delete sound alarms of newEvent
Таким образом, к сожалению, отключение тревоги по умолчанию путем манипулирования ее свойствами не вариант.