如何使用AppleScript在OS X中的“提醒”应用中修改选定的提醒

时间:2014-03-04 00:00:31

标签: applescript reminders

问题标题说明了一切。我基本上是尝试使用AppleScript设置已创建的提醒的截止日期(请参阅我创建的帖子here以获取更多背景信息)。我现在可以使用AppleScript代码提交截止日期的新提醒:

tell application "System Events" to set FrontAppName to name of first process where frontmost is true
if FrontAppName is "Reminders" then
    tell application "Reminders"
        set duedate to (current date) + (2 * days)
        make new reminder with properties {name:"New Reminder", due date:duedate}
    end tell
else
    display dialog "failed to make new reminder!"
end if

但不知道如何将newReminder设置为“当前提醒”。有任何想法吗?我到目前为止所有代码都是:

tell application "System Events" to set FrontAppName to name of first process where frontmost is true
if FrontAppName is "Reminders" then
    tell application "Reminders"
        set currentReminder to current reminder
        set due date of currentReminder to current date
    end tell
else
    display dialog "failed to make new reminder!"
end if

添加截止日期(不提醒我的日期)已经成为OS X社区中一段时间​​要求的功能,我想为此做一个合理的解决方法。目前设置它并不简单,不知道为什么。查看论坛帖子,例如: https://discussions.apple.com/thread/4142949?start=0&tstart=0 https://discussions.apple.com/message/24428695#24428695

非常感谢任何帮助。

2 个答案:

答案 0 :(得分:3)

我认为没有办法获得所选提醒。使用突出显示的选择或插入点。也许你可以使用提醒来匹配某个属性。

tell application "Reminders"
    try
-- select a reminder modified in the last 5 minutes
        set thisReminder to last reminder whose modification date is greater than ((current date) - 300)
    on error
-- if not one, then select the last reminder in a particular list
        set thisReminder to last reminder of (first list whose name is "Office") whose completed is false  -- can leave off the list filter to just get last created reminder
    end try
end tell

set due date of thisReminder……

此脚本允许您创建一个提醒,然后以编程方式设置您在过去5分钟内创建的提醒的截止日期(当然可以缩短窗口)

答案 1 :(得分:-1)

我不确定这会有多强大,你需要给它进行大量的测试,但似乎最新的提醒是列表中的最后一个“获取属性”。所以,你可以尝试这样的事情:

tell application "Reminders"
    activate
    set myRemList to every reminder as list
    set myReminder to item -1 of myRemList
    set due date of myReminder to (current date) + (2 * days)
end tell