【问题标题】:How do you modify a selected reminder in the Reminders app in OS X with AppleScript如何使用 AppleScript 在 OS X 的“提醒”应用中修改选定的提醒
【发布时间】:2014-03-04 00:00:30
【问题描述】:

问题标题说明了一切。我基本上是在尝试使用 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

非常感谢任何帮助。

【问题讨论】:

    标签: applescript reminders


    【解决方案1】:

    我认为没有任何方法可以获取选定的提醒。使用突出显示的选择或插入点。也许您可以使用提醒匹配某个属性。

    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 分钟内创建的提醒的到期日期(当然可以缩短窗口)

    【讨论】:

      【解决方案2】:

      我不确定这会有多强大,您需要对其进行大量测试,但是当您执行“获取属性”时,最近的提醒似乎是列表中的最后一个。所以,你可以试试这样:

      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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-02-16
        • 1970-01-01
        • 1970-01-01
        • 2012-12-02
        • 1970-01-01
        • 2013-10-06
        • 2012-05-28
        相关资源
        最近更新 更多