Accessing Things 3 "Today" List With Keyboard Maestro

Screenshots would help us immensely here :slight_smile:

Fair point! :slight_smile: Attached.



CleanShot 2022-08-04 at 07.15.07@2x

And of course now I see the issue. Append to Variable vs. Save to Variable.

2 Likes

image

This is great and has been super helpful. One question ... how would you further filter the Today list using tags? I'm entirely unable to figure it out. Thanks!

Perhaps, for example:

Things today list filtered by tag.kmmacros (2.4 KB)


(.flatMap, with a function that returns its value wrapped in [ ... ], combines the roles of .map and .filter, if we return an empty list ([]) for values that we want to skip )


Expand disclosure triangle to view JS source
(() => {
    "use strict";

    const
        things = Application("Things3"),
        todayList = things.lists.byName("Today");

    const
        kme = Application("Keyboard Maestro Engine"),
        tagName = kme.getvariable("thingsTagName");

    return [
        `Filtered by tag "${tagName}":\n`,
        ...todayList.toDos()
        .flatMap(
            toDo => toDo.tags.name().includes(tagName) ? (
                [`- [] ${toDo.name()}`]
            ) : []
        )
    ]
    .join("\n");
})();

Brilliant. Thank you so much for taking the time. I notice that it comes up empty if the tag is applied at the Area level. (For example I apply a Work tag to my Work Area so that in the today list I can filter using the "work" tag...if that makes sense) Is there a way for that to work?

I don't use Things myself, so not tested, but it looks as if you may be able to replace the code above with something like:

Expand disclosure triangle to view JS source
(() => {
    "use strict";

    const
        things = Application("Things3"),
        todayList = things.lists.byName("Today");

    const
        kme = Application("Keyboard Maestro Engine"),
        tagName = kme.getvariable("thingsTagName");

    return [
        `Filtered by tag "${tagName}":\n`,
        ...todayList.toDos()
        .flatMap(
            toDo => toDo.tags.name().includes(tagName) || (() => {
                const maybeArea = toDo.area();

                return null !== maybeArea && maybeArea.tags.name()
                .includes(tagName);
            })() ? [`- [] ${toDo.name()}`] : []
        )
    ]
    .join("\n");
})();
1 Like