Is Reminders App Linkable?

Thank you - egg on my face for not reading the legend more carefully.

FWIW though - maybe the title and intro paragraph could be clarified? And/or maybe the “unlinkable” icon could be in red or otherwise more obviously distinguished from the thumbs-up.

image

Anyway and more importantly - Reminders does have Applescript support. What Applescript feature is missing to make it linkable?

1 Like

Reminders has an AppleScript dictionary. But it it is not linkable — can’t get the URL or title of a reminder.

list and reminder exist but there is no way to convert these to usable variables in a script?

image

image

not to my knowledge. I’d love to be shown wrong. (I’m somewhat of a Popperian :blush: [but Lakatos was closer to the mark IMHO]. )

1 Like

That’s an obscure reference. :slight_smile:

1 Like

I just want to share a script which syncs due reminders to the Calendar app and it also links back to the original reminder. So it contains a way to link to specific reminders.

This undocumented x-apple-reminderkit://REMCDReminder/${UUID} URL scheme works on the latest version of iOS and macOS. The ${UUID} part can be found via AppleScript.

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

property calendarName : "Reminders" -- This is the name of your calendar

tell application "Calendar"
	set calendarElement to calendar calendarName
	tell calendar calendarName
		set theEvents to every event
		repeat with currentEvent in theEvents
			delete currentEvent
		end repeat
	end tell
end tell

tell application "Reminders"
	set theReminders to every reminder whose completed is false and (due date > (current date) or due date < (current date)) and (name of container is not "Reminders")
	repeat with theReminder in theReminders
		set theName to name of theReminder
		set theBody to body of theReminder
		set theDueDate to due date of theReminder
		set theURL to the id of theReminder
		set theURL to do shell script "echo \"" & theURL & "\"|sed 's/x-apple-reminder:\\/\\//x-apple-reminderkit:\\/\\/REMCDReminder\\//g'"
		
		tell application "Calendar"
			tell calendarElement
				if not (exists (first event whose (start date = theDueDate) and (summary = theName))) then
					set theEvent to make new event with properties ¬
						{summary:theName, start date:theDueDate, end date:theDueDate, url:theURL, allday event:true} at calendarElement
				end if
			end tell
		end tell
	end repeat
end tell

The only problem remaining for Hook right now that there no scripting API that I’m aware of to get the currently selected reminder.

2 Likes

I figured it out how to get the selected reminder from Reminders via AppleScript. The only issue now is that it doesn’t work in Hook, since it doesn’t have access to the Reminders database in the Privacy preference pane. The script works fine from apps which has access to the Reminders database, in this case Script Debugger, see the video below.

Questions is @LucB: how can I get Hook to request access to the Reminders database?

Here’s the script.

https://static.decoding.io/media/Get%20Link%20to%20Selected%20Reminder.scpt

to findAndReplaceInText(theText, theSearchString, theReplacementString)
	set AppleScript's text item delimiters to theSearchString
	set theTextItems to every text item of theText
	set AppleScript's text item delimiters to theReplacementString
	set theText to theTextItems as string
	set AppleScript's text item delimiters to ""
	return theText
end findAndReplaceInText

tell application "System Events"
	tell its application process "Reminders"
		tell its window "Reminders"
			tell its splitter group 1
				tell its UI element 3
					tell its UI element 2
						tell its UI element 1
							set reminderOutline to first UI element whose selected is true
							set reminderDescription to accessibility description of UI element 1 of reminderOutline
						end tell
					end tell
				end tell
			end tell
		end tell
	end tell
end tell

if reminderDescription contains "Completed, " then
	set theReminderName to findAndReplaceInText(reminderDescription, "Completed, ", "")
end if

if reminderDescription contains "Incomplete, " then
	set theReminderName to findAndReplaceInText(reminderDescription, "Incomplete, ", "")
end if

tell application "Reminders"
	set theReminder to the first reminder whose name is theReminderName
	set theURL to the id of theReminder as text
	set theURL to do shell script "echo \"" & theURL & "\"|sed 's/x-apple-reminder:\\/\\//x-apple-reminderkit:\\/\\/REMCDReminder\\//g'"
	
	return "[" & theReminderName & "](" & theURL & ")"
end tell
1 Like

Thanks all regarding this. We’ll add Reminders support in Hook 3.4. If all goes well, Hook 3.4 will have a short release cycle, but we don’t have an ETA yet.

This is great, but it will only work if the Reminder does not have any additional metadata: due date, notes, link from share sheet, etc.

For example, it does not work, if:

  1. The Reminder has any value in the Notes field. There will be an additional “, $note_contents” added to your string, so the reminder will not be found by the title.
  2. The Reminder has a system hyperlink. Ex. In the Notes app, use the share sheet to create a reminder. There will be an additional “, From Notes” added to your string

I guess you could remove everything after the comma, but then you would not be able to have any commas in the name of your reminder (which is an edge-ish case).

Yes, the solution we have will work.

first, thanks again to @zsbenke for great input into using Hook with Apple Reminders.

Two corrections re my:

First, in looking at this further, the UI scripting for this may be brittle; i.e., subject to changes if Apple updates the UI. Also, there’s a line

set theReminder to the first reminder whose name is theReminderName

that is slow if there are thousands of Reminders; slow even on a MacBook Pro 2021 Pro Max in that case.

So the best approach may be to publish an adaptation of the script online once we’ve published an underlying change to Hook. After further testing we could merge it into the actual app. But till then Hook Pro (3.3.2+) users can simply copy/paste it into Hook’s integration script editor.

Secondly, the fix is likely to come in Hook 3.3.2 rather than Hook 4. We have only a bit of polishing and additional testing left to do for Hook 3.3.2. So hopefully this come fast.

The web page will be: Using Hook with Apple Reminders – Hook.

Before adding any new apps to the list of apps that work with Hook, I’d much rather you find ways - brittle though they may be - to work with the standard, out-of-the-box, Apple apps, such as Reminders.

3 Likes

For giggles, I tried making a Shortcut like:

Find “All Reminders” where “Name” “is” “”

and it’s dog slow, too. I guess behind the scenes it’s using the same mechanism.

1 Like

Hook 3.3.2 now enables Hook Pro users to add a script for Reminders per:

the link to the help page is Using Hook with Apple Reminders – Hook. Thank you again.

1 Like

No problem! Hopefully it will be enough as a temporary solution, although I would ping Apple in Feedback Assistant to add a selected reminder option to AppleScript like Notes has.

1 Like

I’ve just found this & this is heaven sent since I use it to run my personal life. I’ve read through the documentation here Using Hook with Apple Reminders – Hook
This doesn’t work at all with lists I have shared between family members. Is that a limitation?
Once I invoked it I got this error and it looks up Reminders with the rainbow pinwheel.
image

Any idea how I can resolve this?

Even on an M1 Mac, if you have thousands of reminders it’s slow. If you allow it to Continue it should eventually finish. We should add latency to the list of caveats.

Apple Reminds has a URL scheme, so using the URLs is fast. But they don’t provide an API to quickly get the reminder of the currently selected item , so the script is a bit convoluted. I believe there are Link-friendly Mac Apps that integrate with Reminders; if so, they would have lower latency.

I’ve been using this code for a while now, thanks @zsbenke . One note is that, at least on Ventura 13.2, it fails if a reminder has a priority level assigned to it (the !!! UI shows up in the expected reminder title location).

I’ve revised the code to adapt to this (roughly, it will fail if the reminder title’s first character is !.. this can be refined further by doing a more strict string check where I look for !) and it now works with and without priorities assigned.

If this code looks good to everyone, mayb @LucB can update the Using Hookmark with Apple Reminders – Hookmark page with it?

set sysinfo to system info
set osver to system version of sysinfo

considering numeric strings
	set isMonterey to osver ≥ "12"
end considering

tell application "System Events"
	tell its application process "Reminders"
		tell its window "Reminders"
			tell its splitter group 1
				tell its UI element 3
					tell its UI element 2
						tell its UI element 1
							if isMonterey then
								set reminderOutline to first UI element whose selected of UI element 1 is true
								set theReminderName2 to value of UI element 2 of UI element 1 of UI element 1 of reminderOutline
								set theReminderName3 to value of UI element 3 of UI element 1 of UI element 1 of reminderOutline
							else
								set reminderOutline to first UI element whose selected is true
								set theReminderName2 to value of UI element 2 of UI element 1 of reminderOutline
								set theReminderName3 to value of UI element 3 of UI element 1 of reminderOutline
							end if
						end tell
					end tell
				end tell
			end tell
		end tell
	end tell
end tell
tell application "Reminders"
	try
		if character 1 of theReminderName2 = "!" then
			set theReminderName to theReminderName3
		else
			set theReminderName to theReminderName2
		end if
		set theReminder to the first reminder whose name is theReminderName
		set theURL to the id of theReminder as text
		set theURL to do shell script "echo \"" & theURL & "\"|sed 's/x-apple-reminder:\\/\\//x-apple-reminderkit:\\/\\/REMCDReminder\\//g'"
		return "[" & theReminderName & "](" & theURL & ")"
	on error errMsg
		display dialog "ERROR: " & errMsg
	end try
end tell
2 Likes

I’ve been using this code for a while now, thanks @zsbenke

@ethanschoonover Thank you! I’m honored. :slight_smile:

I actually gave up using this script, because Reminders Apple Script integration is so slow, it is barely usable.

1 Like

Yeah I’ve been trying to use shortcuts to pull the selected reminder title as that would speed things up, but no joy so far. regardless, appreciate the script!

1 Like