How to add a new tag to a tag field?

I am trying to add a new entry into a “tags” field (like the field in Finder where you can assign existing or enter new tags) but cannot figure out how.

I suppose this needs to be done through an AppleScript but I could not find any information or examples on how to do this. The only thing I could figure out is that the control type is a text field, but it does not have any text itself, instead it has a number of child text fields, each representing one of the text “bubbles”.

I’d be grateful for any hints on how to solve this!


Hey Guy,

You need to be more specific.

Where exactly are you emplacing tags.

What app?

The Finder is easy.

Menu item “Tags…”

Paste tab-dlimited tags in the pop-up sheet.

This can be scripted for the Finder, although it requires ASObjC

See Shane Stanley’s [FileTagsLib v1.0.0 AppleScript Library] (

You can use the library itself, or you can open it in the Script and raid the handlers out of it.


Hey Chris,

the app in question is BusyCal from BusyMac. When clicking on a calendar event, a floating window with the event details is displayed. One of the fields displays the keywords of the event in the form of a “tags” field.

It is not possible to simply press TAB “n” times to set the input focus to the tags field, because depending on the type of event, different controls in the window will be enabled or disabled. So this number “n” is not constant.

For this situation, I do not know of any workaround like with assigning “Finder Tags” to a file that you mentioned.

So in my mind, the most robust (and only?) solution is to adress this control directly through AppleScript. I know how to read it’s values, but not how add a new one.


Hey Guy,

I have BusyCal, and I’m not seeing a “tags” field in any of the events. Can you show me with a screenshot?

As for scripting – BusyCal only has the basic AppleScript suite and NO BusyCal suite – which means it isn’t AppleScriptable. However, there is an url-scheme:


Hey Chris,

you have to enable the display of tags and other fields in BusyCal/Preferences…/Info Panel.

I am aware that BusyCal has no dedicated AppleScript suite. That is the reason I rely on KM & GUI scripting to automate it. That actually seems to work quite well, except for the “tags field” issue.


Hey Guy,


Okay, the tags field label looks consistent in the different dialogs.

Try using the Click at Found Image action to find the tag label and then click at the appropriate offset.

Click at Found Imate.kmmacros (16 KB)

It works for me with every type of event I've tried.

You'll probably need to recreate the image (my Mac is not Retina).



You might try shift-tabbing (backwards) through the entry fields rather than tabbing forwards; possibly the tag field is a consistent number of fields from the end of all event types.

Otherwise, it does indeed seem that there’s no good way of doing this. Were BusyMac to provide a menu command — or even a contextual-menu command — for setting an event’s tags, you’d be much better off.

There is one other possibility, though, which is to use a Keyboard Maestro “Found Image” check in an “Until” action. I try to use these only as a last resort because they break pretty easily. (You have been warned.) You’d want to:

  1. In BusyCal, tab into the tags: field in an Event Info window.
  2. Take a screen shot encompassing just the one line that shows tags: and the left side of the tags field with the focus ring; take care not to grab much of the field itself, since you probably want this macro to work even if there is already a tag present in the field — that is, you shouldn’t be able to tell from the screen shot whether or not there is a tag in the field.
  3. Set up your macro like this: and then drag-n-drop your screen shot into the image well next to the fuzzy e.

Since these tend to break (especially with OS upgrades or when you change appearance-related preferences or when BusyMac changes the method they use for constructing Event Info windows...) — you have been warned again! — you should probably also add a further condition to make sure your macro doesn’t just type tab forever:

(“20” is a generous guess, but BusyMac does let one stuff an awful lot of metadata into that info box!)

This is not only a breakable solution, it potentially is rather CPU intensive. Make sure that you select the window with title option rather than the default all screens.

Finally, if you can (at least temporarily) arrange things on your monitor such that you can see both the “Execute Actions Until Conditions Met” step in Keyboard Maestro and the BusyCal “Event Info” floater, you should further tune the macro by:

  1. In BusyCal, again tab into the tags: field.
  2. With BusyCal still active, look at the gray text to the right of “any of the following are true”.
    a. If you see “(currently false)” (as in the image above), go back to Keyboard Maestro and nudge the slider further toward the fuzzy e.
    b. If you see “(currently true)”, nudge the slider further toward the clear e.
  3. Repeat, making sure not to skip step #1 (since the focus ring in the tab field disappears when you shift to Keyboard Maestro).

The goal is to end up with the slider two or three pixels to the right of the spot where it shifts from “(currently false)” to “(currently true),” which will maximize your chances of Keyboard Maestro properly spotting the image without any false positives.

— Erik

Wow, talk about a hack! :slight_smile:

@Chris: thank you for this sample. In my first tests, I found it to work quite well!

@ErikHH: Thanks you for your detailed explanations. It seems your image detection solution uses KM7 because in KM 6 I could not find the “in window with title” addition. Being on 10.9, I am currently stuck with KM 6.

I am aware that this is not a very robust solution, but for the time being, it will have to do.

I also thought about “back-tabbing” to reach the control, but again this is not working because the number of Shift-TAB presses required to reach the field varies depending on event type.

Thanks again,