Input future dates with Keyboard Maestro

One aspect of my job is communicating dates - due date, follow up date, etc. For years I've used the following Keyboard Maestro macro to give me the day/date of the weekday called out by the macro.

For example, typing .mon will trigger a Keyboard Maestro macro to type in the short name of the weekday and the date in parenthesis for the date of the next coming Monday - Mon (12/22).

On a current project, we're in a longer design phase and this meant I needed to start dealing with dates further out - 2 weeks or more. For about a week I thought the change to my script in the macro was working perfectly.

set theDate to (current date) + 8 * days
repeat until weekday of theDate = Monday
set theDate to theDate + 1 * days
end repeat
"Mon (" & (text -2 thru -1 of ("0" & (month of theDate as integer))) & "/" & (text -2 thru -1 of ("0" & (day of theDate as integer))) & ")" as string

This would give me 2 weeks out from today - Mon (12/29) - like I wanted. Then I started looking at the tedious work I would have to do to replicate the "2 week" macros for dates 3 weeks out and dates 4 weeks out. I decided I needed to look at a single macro that would dynamically generate the short name of the day of the week based on the day of the week the macro is run.

Breaking down the parts

The new macro would need an AppleScript to do two parts:

  1. Identify the date value 14 days from today.
  2. Dynamically generate the short name of the day of the week.

The first part of the macro I wanted was pretty easy - I changed my script from adding 8 * days to adding 15 * days. 1

The harder part was getting the script to stop requiring a hard code for the short name of the day. Getting the short name of the day of the week is easy to in other programming languages, but AppleScript does what AppleScript does... it makes it an educational experience.

I tried a few different ways to get to a short name, but eventually gave in and did a quick search on a great reference site -MacScripter.com. One quick search and I found exactly what I needed - Localised weekday?. This gave a simple breakdown on how to shorten the name of the day of the week:3

set shortDayName to (text items 1 thru 3 of ((current_date) as text)) as text

Piecing it all together

The script hasn't changed much from the version I originally started to work with, but the small alterations have made it much easier to manage.

set current_date to (current date) + 8 * days
repeat until weekday of current_date = weekday of (current date)
set current_date to current_date + 1 * days
end repeat
-- credit: https://www.macscripter.net/t/localised-weekday/64388
set shortDayName to (text items 1 thru 3 of ((current_date) as text)) as text
--
(("" & shortDayName & " (" & (month of current_date as integer) as string) & "/" & (day of current_date as integer) as string) & ")" as string

Now when I type +2w anywhere on my Mac, I will get day of the week and the date two weeks from now. I replicated the macro for +3w and +4w as well. 2


  1. You need to add * days to the day addition, otherwise you're adding the number of seconds to a date value. 

  2. My wife loved my analogy to her stenography keyboard when I explained what I was working over the weekend. 

  3. My original plan involved a bunch of if / else loops to review each day of the week. Functional, but not elegant. 



Previous posts:

  1. Getting OmniFocus Task to physical paper

    Call me old school, but there are times I prefer paper over digital. I found I have a disconnect from being able to collect notes or ideas to capturing action items in a meeting, and then religiously getting these items documented into a digital format. This led me to start …

  2. Replicate ISO Date from macOS in Drafts

    Summer is here1 and I'm starting to work in odder locations - some by choice and some due to my work schedule. Normally I work from a Mac, but my travel schedule has led me back to my iPad to get my work done. I love the portability of my …

  3. New Microsoft Windows App for macOS

    Microsoft announced a new Windows App yesterday. This kind of announcement normally doesn't send shock waves in the Apple community until you get an explanation on what the app really is.

    Windows App is your gateway to Azure Virtual Desktop, Windows 365, Microsoft Dev Box, Remote Desktop Services, and remote …

  4. Add Spacers to your macOS menu dock

    I've been able to convert a few more friends and family members to the Apple family. So I'm starting to get more questions on customizing their Apple device. One of my favorite customizations is adding spacers into my dock to help separate apps that I keep in my dock. So …

  5. A new GTDesque Shortcut

    Yesterday Jason Snell (@jsnell) shared a link to his post about a Shortcut he found that will review your calendar and give you a list of dates/times you're available. At first this seemed like a "kinda of ok" Shortcut after I read Jason's post because the Shortcut only pulled …

Top