3

The question title says it all. I'm basically trying to set the due date of an already created reminder using AppleScript (see the post I created here for more background). I can currently make a new reminder with a due date using the AppleScript code:

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

But have no clue how to set newReminder to "current reminder." Any ideas? All I have so far for the code is:

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

Adding a due date (not remind me date) has been a feature requested for a while in the OS X community that I'd like to make a reasonable workaround for. Currently it's not straightforward to set it, no clue why. See forum posts such as: https://discussions.apple.com/thread/4142949?start=0&tstart=0 https://discussions.apple.com/message/24428695#24428695

Any help is much appreciated.

thed0ctor
  • 1,350
  • 4
  • 17
  • 34

2 Answers2

3

I don't think there is any way to get the selected reminder. With a highlighted selection or with the insertion point. Perhaps you can use get a reminder the matches a certain property.

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……

This script allows you to create a Reminder, and then programmatically set the due date of the Reminder that you created in the last 5 minutes (can shorten the window, of course)

jweaks
  • 3,674
  • 1
  • 19
  • 32
-2

I'm not sure how robust this will be, you'd need to give it a lot of testing, but it seems the most recent reminder is the last in the list when you do 'get properties'. So, you might try something like this:

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
applehelpwriter
  • 488
  • 3
  • 8