Create new entry from text date or date and time

I see there are some longish, threads on similar topics with very complex KM macros, but my quest is much simpler;

Select a date or date and time in text anywhere
Invoke a KM macro from the Services menu brought up by control click.

The macro simply does this:
Copy the selected text
Choose File > New Event

Calendar can interpret normal text in this way.

I know how to do the KM macro, but not how to get a simple trigger in the Services Menu. Or am I missing something simple?

Your question is interesting. I didn't know calendar could do that. So I like your idea, very much.

But I have a few areas of concern.

  1. First, you are asking that the macro be installed as a service. To me, this is a separate topic and should be in a different thread because it's unrelated to the Calendar issue and probably a complicated thing to solve. I found a thread on this website about installing macros as a service, which I started, and I never resolved the problem.
  2. Second, you are insisting that the trigger for the macro be control-click. That may be possible, but did you check if your mouse's buttons work in the USB Device Key Trigger? I'm not sure if all mice support that trigger.
  3. Thirdly, you may not even need a mouse or keyboard trigger at all. If you created a macro that was triggered based on a change in clipboard text, and did a little filtering to see if the new clipboard "probably contained a date" then that's all you need to decide whether to paste the text into Calendar. This would be a really cool idea.

That third idea is so cool I'll write the code in 5 minutes and paste it here. OKAY, here's a cool macro that doesn't even require a trigger, apart from the standard CMD-C you use to copy text.... The trigger for this macro is "the system clipboard changes".

Auto-Calendar Macro (v10.0.2)

Auto-Calendar.kmmacros (5.6 KB)

I can imagine several ways to improve this macro, but I won't bother if you don't think this is a good solution. It's cool this way because you don't have to memorize a hotkey. My brain can hold only a limited number of hotkeys. But I'll never forget how to copy text. (CMD-C)

Here's one I prepared earlier.

Test Create Calendar Event.kmmacros (4.5 KB)

It doesn't use the Services facility since the Calendar app is AppleScript scriptable.

It copies whatever date text you've selected and then creates a calendar event but to do so it needs to know

  • which calendar
  • the name of the event

and the macro sets these up for you, so you can change them if you wish/need to.

EDIT: just found a small error so I've updated the macro.


1 Like

Thanks for the replies.
Of course, I could just put the macro trigger in Global Macros with a trigger of The status menu item is selected.
The reason I thought of the Services menu is because it's routine to control click to do something to a text selection. macOS has many actions built in.
I was just surprised to find that add item to Calendar isn't built in.
I will investigate Automator, which can create Services.

Once you have made your Keyboard Maestro Calendar Macro, you can trigger it from the Services Menu.

EDIT - Having just tried this it does show up in the Services Menu - but not in the right-click Services Menu... not sure why. Does anyone here know?

Click to Show Image: From Main Menu Services Menu

Click to Show Image: From Right-Click Context Menu Services Menu

1 Like

It turns out that from TextEdit a control click will offer Create Event [in] as the top choice. No need to use the Services Menu.
No such choice when control clicking in Safari, but you can choose New TextEdit Window Containing Selection. Then you can use the above.

I tried Is it possible to trigger a Macro in regular right-click context menu? - #5 by NaOH with no luck.

My simple macro works from the Keyboard Maestro menubar.

1 Like

Out of interest, what Mac OS are you on? In Monterey that choice isn't there.

I'm on Mojave and this is what I get in TextEdit when I right-click on a selected date:

KM 0 2022-02-22_22-56-02

Maybe you're not seeing it @Zabobon because you haven't selected any text that is a meaningful date??

1 Like

macOS Monterey on an M1 iMac:

1 Like

Yes - that was it.

With my own Keyboard Maestro Calendar event Macro, I start by selecting some text for the Calendar note, rather than the date so, I was thinking this would be the same. But makes sense the inbuilt context menu would act on a date.

1 Like

Thanks @Sleepy, I removed the date stuff so I can create a new calendar event with the title of whatever is selected.

Keyboard Maestro Actions.kmactions (2.6 KB)

Keyboard Maestro Export

I used PopClip per:

Using the format (without the opening and closing quotes) in a TextEdit doc:
'# popclip
name: calendar
Icon: symbol:calendar
url: kmtrigger://macro=63AF5B8E-E09E-4AC5-A2F1-94E527E67BD5'

I was able to have the SF Symbols icon show in PopClip and trigger the KM macro using its URL as seen in the last line.

Looks like this: