Keyboard Shortcut to create new Reminder

Keyboard Shortcut to create new Reminder

This code will allow you to create a new Reminder based on either an entered topic or the contents of the clipboard.

You will be prompted to select the List to save the Reminder to along with the time the Reminder is due for completion.

There is also an option to paste in the contents of the clipboard into the Notes field.

Step 1 - Create quick action In Automator


Paste in this code

# Title: Create new Reminder v2
# By woteva65@icloud.com
# Inspired by code written by Michael Kummer

try
	#Clipboard
	set _input to the clipboard -- grab clipboard
	
	# Reminder Name
	display dialog "What would you like to be reminded about? 	
 	(leave blank to use clipboard)" default answer ""
	set reminder_name to text returned of result --get input
	
	if reminder_name is equal to "" then
		set reminder_title to _input -- use clipboard contents
	else
		set reminder_title to reminder_name -- use input
	end if
	
	# Reminders List	
	tell application "Reminders"
		set lName to name of every list
		set dName to name of default list
	end tell
	tell me to activate
	set lName to choose from list lName with prompt "Select List" default items {dName} without empty selection allowed
	if lName is false then
		return 1
	else
		set lName to lName as string
	end if
	
	set RemindersList to lName as text
	
	if RemindersList is "false" then return
	
	# Set Reminders Note
	set question to display dialog "Include Clipboard as a Note?" buttons {"Yes", "No"} default button 2
	set answer to button returned of question
	
	#Follow up Time
	(choose from list {"2 hours", "Tonight", "Tomorrow", "2 Days", "End of Week", "1 Week", "2 Weeks", "1 Month", "3 Months"} default items "End of Week" OK button name "Create" with prompt "Set follow-up time" with title "Create Reminder")
	
	set reminderDate to result as text
	
	# Exit if user clicks Cancel
	if reminderDate is "false" then return
	
	if reminderDate = "2 Hours" then
		set remindMeDate to (current date) + 2 * hours
		--set time of remindMeDate to 120 * minutes
		
	else if reminderDate = "Tonight" then
		# add 0 day and set time to 17h into the day = 5pm
		set remindMeDate to (current date) + 0 * days
		set time of remindMeDate to 60 * 60 * 17
		
	else if reminderDate = "Tomorrow" then
		# add 1 day and set time to 9h into the day = 9am
		set remindMeDate to (current date) + 1 * days
		set time of remindMeDate to 60 * 60 * 9
		
	else if reminderDate = "2 Days" then
		
		set remindMeDate to (current date) + 2 * days
		set time of remindMeDate to 60 * 60 * 9
		
	else if reminderDate = "End of Week" then
		# end of week means Sunday in terms of reminders
		# get the current day of the week
		set curWeekDay to weekday of (current date) as string
		if curWeekDay = "Monday" then
			set remindMeDate to (current date) + 6 * days
		else if curWeekDay = "Tuesday" then
			set remindMeDate to (current date) + 5 * days
		else if curWeekDay = "Wednesday" then
			set remindMeDate to (current date) + 4 * days
		else if curWeekDay = "Thursday" then
			set remindMeDate to (current date) + 3 * days
		else if curWeekDay = "Friday" then
			set remindMeDate to (current date) + 2 * days
		else if curWeekDay = "Saturday" then
			set remindMeDate to (current date) + 1 * days
			# if it's Sunday I'll set the reminder for Sunday next week
		else if curWeekDay = "Sunday" then
			set remindMeDate to (current date) + 7 * days
		end if
		
		set time of remindMeDate to 60 * 60 * 9
		
	else if reminderDate = "1 Week" then
		
		set remindMeDate to (current date) + 7 * days
		set time of remindMeDate to 60 * 60 * 9
		
	else if reminderDate = "2 Weeks" then
		
		set remindMeDate to (current date) + 14 * days
		set time of remindMeDate to 60 * 60 * 9
		
	else if reminderDate = "1 Month" then
		
		set remindMeDate to (current date) + 30 * days
		set time of remindMeDate to 60 * 60 * 9
		
	else if reminderDate = "3 Months" then
		
		set remindMeDate to (current date) + 90 * days
		set time of remindMeDate to 60 * 60 * 9
		
	end if
	
	# Save Reminder
	if answer is equal to "Yes" then
		tell application "Reminders"
			tell list RemindersList
				set reminder_id to make new reminder with properties {remind me date:remindMeDate, name:reminder_title, body:_input} --create reminder
			end tell
		end tell
	end if
	
	if answer is equal to "No" then
		tell application "Reminders"
			tell list RemindersList
				set reminder_id to make new reminder with properties {remind me date:remindMeDate, name:reminder_title} --create reminder	
			end tell
		end tell
	end if
	
	#Error Message	
on error
	display dialog "Oops, something went wrong." --throw an error if something goes wrong
end try

Save Service

Step 2 - Create new Keyboard Shortcut

In System Preferences go to Keyboard -> Shortcuts -> Services -> (Name of Service) and enter key combination.

Demonstration

https://www.youtube.com/watch?v=glR-9Xa7dIg

1 Like

Code updated to remove hard coded lists, now all available lists will be shown

Is there a way that if you enter items with a comma separating them, that it could create multiple entries? I’m thinking this would be great for grocery list Reminders.

Probably possible but you would how to create a routine to parse the string of items that you want added then loop the creation process.

From what I can see Reminders does not allow you to add multiple items to a list via Siri which I thought may be an option, but Things does seem to have the functionality, so it must be possible but would require Apple updating Reminders to allow it to happen.

1- Thank you for this!
2- I tried to edit your script to fit a specific need but I keep getting an error “Expected end of line, etc. but found “try””. Could you tell me what I’m doing wrong?
try

	# Reminder Name
	display dialog "What would you like to be reminded about?" default answer ""
	set reminder_name to text returned of result --get input
	
	set reminder_title to "You need to process something"
	
	# Reminders List	
	tell application "Reminders"
			set RemindersList to Reminders
	
	if RemindersList is "false" then return
	endtell
	

	
	#Follow up Time
	(choose from list {"Tonight", "Tomorrow", "End of Week", "1 Week", "1 Month", "3 Months"} default items "End of Week" OK button name "Create" with prompt "Set follow-up time" with title "Create Reminder")
	
	set reminderDate to result as text
	
	# Exit if user clicks Cancel
	if reminderDate is "false" then return
		
	if reminderDate = "Tonight" then
		# add 0 day and set time to 17h into the day = 5pm
		set remindMeDate to (current date) + 0 * days
		set time of remindMeDate to 60 * 60 * 20
		
	else if reminderDate = "Tomorrow" then
		# add 1 day and set time to 9h into the day = 9am
		set remindMeDate to (current date) + 1 * days
		set time of remindMeDate to 60 * 60 * 20
		
	else if reminderDate = "End of Week" then
		# end of week means Sunday in terms of reminders
		# get the current day of the week
		set curWeekDay to weekday of (current date) as string
		if curWeekDay = "Monday" then
			set remindMeDate to (current date) + 6 * days
		else if curWeekDay = "Tuesday" then
			set remindMeDate to (current date) + 5 * days
		else if curWeekDay = "Wednesday" then
			set remindMeDate to (current date) + 4 * days
		else if curWeekDay = "Thursday" then
			set remindMeDate to (current date) + 3 * days
		else if curWeekDay = "Friday" then
			set remindMeDate to (current date) + 2 * days
		else if curWeekDay = "Saturday" then
			set remindMeDate to (current date) + 1 * days
			# if it's Sunday I'll set the reminder for Sunday next week
		else if curWeekDay = "Sunday" then
			set remindMeDate to (current date) + 7 * days
		end if
		
		set time of remindMeDate to 60 * 60 * 20
		
	else if reminderDate = "1 Week" then
		
		set remindMeDate to (current date) + 7 * days
		set time of remindMeDate to 60 * 60 * 20
		
	else if reminderDate = "1 Month" then
		
		set remindMeDate to (current date) + 30 * days
		set time of remindMeDate to 60 * 60 * 20
		
	else if reminderDate = "3 Months" then
		
		set remindMeDate to (current date) + 90 * days
		set time of remindMeDate to 60 * 60 * 20
		
	end if
	
	# Save Reminder
	if answer is equal to "Yes" then
		tell application "Reminders"
			tell list RemindersList
				set reminder_id to make new reminder with properties {remind me date:remindMeDate, name:reminder_title, body:_input} --create reminder
			end tell
		end tell
	end if
	
	if answer is equal to "No" then
		tell application "Reminders"
			tell list RemindersList
				set reminder_id to make new reminder with properties {remind me date:remindMeDate, name:reminder_title} --create reminder	
			end tell
		end tell
	end if
end try

Get rid of the tryend try enclosures. There are very few reasons in AppleScript to have to use try blocks. They’re almost always used (inappropriately) in fragile scripts that potentially break under certain conditions, but where the author of the script was either too lazy or unable to discern the nature of the issue, or how to fix it. It actually ends up making scripts a lot more difficult to debug.

Rule of thumb: only use a try block when you know exactly what error will arise, and under what conditions; and you are using the catch to allow the script to handle the error in a specific, meaningful way.

There are a couple of exceptions, but none worth mentioning here.

The specific problem with the script is in this section:

There’s a space omitted between the words end and tell. On a separate note, the line above it is wrong, as RemindersList will never equal "false".

The last half of your script is problematic too: you haven’t define a variable called answers, so that will throw an error (or it would if it wasn’t in a try block). And your subsequent use of RemindersList is not a valid reference for the list specifier to use.

I’ve cleaned your script up a bit:

tell (current date) to set [midnight, time] to [it, 0]

set reminder_options to {"Tonight", "Tomorrow Night", "End of Week", ¬
	"1 Week", "1 Month", "3 Months"}
set daysFromNow to {0, 1, 8 - (weekday of midnight), 7, 30, 90}

set reminder_name to the text returned of (display dialog ¬
	"What would you like to be reminded about?" default answer "")
set reminder_note to "You need to process something"
set {reminder_date} to (choose from list reminder_options ¬
	default items {"End of Week"} OK button name {"Create"} ¬
	with prompt {"Set follow-up time"} ¬
	with title {"Create Reminder"}) as list

if the reminder_date = false then return

repeat with i from 1 to the number of reminder_options
	if the reminder_date = item i in the ¬
		reminder_options then exit repeat
end repeat
set numDays to item i of daysFromNow
set reminder_date to midnight + numDays * days + 20 * hours

set reminder_list_name to "My Reminders" -- change this to any name you'd like for your list

tell application "Reminders"
	set myList to a reference to list reminder_list_name
	if not (myList exists) then make new list with properties ¬
		{name:reminder_list_name}
	
	tell myList to set reminder_id to make new reminder ¬
		with properties {remind me date:reminder_date ¬
		, name:reminder_name ¬
		, body:reminder_note} --
	
end tell
1 Like