Accessing Things 3 "Today" List With Keyboard Maestro

I use Things 3 from Cultured Code to collect and organize various tasks. I would like to use KBM to retrieve the tasks from the "Today" list so that I can adjust the format of the task list for use with Obsidian (Markdown format), i.e. - [ ] Task. I expect this will require use of AppleScript to access Things 3... does anyone have any suggestions (or code examples) for how to approach this? Thanks!

Extra credit: it would be helpful to also retrieve the various metadata associated with the task, e.g., the project or Area of the task, notes, subtasks, due dates, tags, etc. Any pointers here would also be appreciated!

References:

  • I expect the work done by @Brian_Martin here may be useful, though I have not yet parsed out the details with regard to my objective.
2 Likes

It might be helpful to unpack what retrieve and adjust mean to you.

You are hoping that someone will write you a script that:

  • generates a text file ?
  • makes adjustments in the Things database ?
  • something else ?

PS if the object of your prayers and sacrifices is a textual list, then the bare bones might have a shape like this:

Things today list (bare bones) Macro (v9.2)

Things today list (bare bones).kmmacros (1.8 KB)

I use this script.

Trigger Things 3 Today Macro (KM v9.2)

Trigger Things 3 Today.kmmacros (4.7 KB)


Note

The AppleScript is modified from script Today of package Things of Raycast community scripts. Improved with the help of Cultured Code's Things 3 AppleScript Documentations.

I use & contributes to KM and Raycast, and both app is a great timesaver.

2 Likes

Thanks! This is helpful.

Stripping it right back, it might be enough to write:

image

Expand disclosure triangle to view JS Source
Application("Things3")
    .lists
    .byName("Today")
    .toDos()
    .map(toDo => `- [] ${toDo.name()}`)
    .join("\n");
1 Like

I am trying to display the number of Things to-dos in the menu bar with KM 10.

Here is what I have attempted:

The Apple Script, when I run in Script Editor, returns a number 7 for the todoCount.

How do I pass this variable back to the "Macro Group" so that it will display as a custom title in the menu bar, or, am I doing this wrong?

Change %todosCount% to %Variable%todosCount%

Then set the output of your AppleScript to a variable named: todosCount

-Chris

1 Like

Ah, thank you @ccstone ... short and sweet answer!

I thought of sharing my macro, for any new persons who wants to show number of Cultured Code's Things to-dos in the menu bar.

This is how it will look:

image

The first number, 11, is the to-do count from the Inbox, while the second number 5, right after the star, a symbol of Today in Things, is the to-do count from Today.

Here is the macro:

The star is actually a Unicode U-2605.

I have two triggers – every 30 min and when the Things app activates.

Here are the codes:

tell application "Things3"
   
   «data utxt2605» as Unicode text
   
   set todayTodos to to dos of list "Today"
   
   set todayCount to the length of todayTodos
   
   set inboxTodos to to dos of list "Inbox"
   
   set inboxCount to the length of inboxTodos
   
   set totalCount to " " & inboxCount & «data utxt2605» & todayCount
   
   return totalCount
   
end tell

Thanks @ccstone for the tip.

Hi guys, is there a way to get icons in the drop down menu from menu bar?

image

I don't see any way to do so at present.

@peternlewis?

This will probably come up more than once.

-Chris

Selecting status menu items is difficult primarily because there is no easy way of specifying them - they don't have names so its hard to identify them.

You can use a Click at Found Image, although even that can be difficult as they often animate or change icons based on various states. If the icon does not animate or change state (or has a known state when you want to select from it), then this can be a good solution, followed by Insert Text by Typing "Menu Name%Return%"

To click relative to an image, you use the Mouse Click action, configure it to be relative to a found image, and take a screenshot of the desired area of the screen using Command-Control-Shift-4, and paste it into the image well on the action. The image has to be unique (which includes not being visible in the action if the image is small enough not to be shrunk in the image well) otherwise Keyboard Maestro will not know where to click. The Display option in the action will allow you to see where Keyboard Maestro is matching.

I have looked into it on multiple occasions, and will no doubt look in to it again, but its a difficult problem.

Hey @peternlewis,

I think the OP wants to know if there's a way to include icons with the menu names.

-Chris

Indeed, that was my question. Menu bar itself has the macro group icon but the drop down menu, which are individual macros, do not have icons. They just have the name of the macro.

Oh, you mean icon icons in the menu names - probably not, it generally does not look very good when you do that.

1 Like

Use the “With title from Variable” option for the Display in menu bar title - that way it will be updated whenever the variable is updated - instantly when the variable is updated, and not at all when it is not, so much better than the periodic update.

2 Likes

Hi Peter, if I use
"With custom title: %Variable%menuCount%",
my menu bar is showing the numbers. But, if I use
"With title from variable: %Variable%menuCount%",
I get blank.

Do these two options refer to different variables?

%Variable%menuCount% is not a variable, it is a text token. menuCount is a variable.

2 Likes

I know this is an old thread but brand new to KBM and gave this a try. Every minute the new numbers for Inbox and Today are appended to my menubar. I've checked but I think I've built the macro group and macro correctly. Is there something simple I'm missing? Thanks for any help.