Applescript 在日历中创建事件,如何删除默认警报?

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

因此,遗憾的是,通过操纵其属性来使默认警报静音是不可能的。

相关内容