Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用AppleScript在OS X的提醒应用程序中修改选定的提醒_Applescript_Reminders - Fatal编程技术网

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

如何使用AppleScript在OS X的提醒应用程序中修改选定的提醒,applescript,reminders,Applescript,Reminders,题目说明了一切。我基本上是在尝试使用AppleScript设置已经创建的提醒的截止日期(更多背景信息,请参阅我创建的帖子)。我目前可以使用AppleScript代码制作一个新的提醒,并注明到期日期: tell application "System Events" to set FrontAppName to name of first process where frontmost is true if FrontAppName is "Reminders" then tell app

题目说明了一切。我基本上是在尝试使用AppleScript设置已经创建的提醒的截止日期(更多背景信息,请参阅我创建的帖子)。我目前可以使用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
添加到期日(而不是提醒我日期)是OSX社区一段时间以来一直要求的功能,我希望为它提供一个合理的解决方案。目前设置它并不简单,不知道为什么。见论坛帖子,如:


非常感谢您的帮助。

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

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

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

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