Quickly Toggle the "Group To-dos by Project or Area" setting in Things3 Using AppleScript and Keyboard Maestro

I often find myself wanting to switch between grouping and not grouping the to-dos in the Today view in the Things app.

I wish there was a quicker way to switch this, but the way to do this is by opening the settings screen each time and toggling the checkbox. Ideally, this would be something the makers of Things app—Cultured Code—would offer in the Today view itself. It feels like this belongs there, with a hot key to switch quickly.

Anyway, for now, I got around it by utilizing the UI scripting method and writing a simple AppleScript, and then firing the script with a keyboard shortcut using Keyboard Maestro.

0:00
/0:06

Files Needed:

  1. AppleScript File: ToggleGroupTodos.scpt
  2. Keyboard Maestro Macro

AppleScript File: ToggleGroupTodos.scpt

This script toggles the setting in Things3:

tell application "System Events"
    -- Activate Things3 application
    tell application "Things3" to activate
    
    -- Delay to ensure the application is in focus
    delay 1
    
    -- Open Preferences window
    keystroke "," using {command down}
    
    -- Delay to allow Preferences window to open
    delay 2
    
    -- Interact with the General tab in Preferences
    tell process "Things3"
        -- Ensure we are in the right tab
        click button "General" of tool bar 1 of window 1
        
        -- Delay to ensure the General tab is active
        delay 1
        
        -- Find and toggle the checkbox
        set groupCheckbox to checkbox "Group to-dos in the Today list by project or area" of window 1
        
        -- Check if the checkbox is unchecked and then check it
        if value of groupCheckbox is 0 then
            click groupCheckbox
        -- If it is already checked, click to uncheck it (toggle behavior)
        else
            click groupCheckbox
        end if
    end tell
    
    -- Close Preferences window
    keystroke "w" using {command down}
end tell

Setting Up the Keyboard Maestro Macro

  1. Create a new macro:
    • Open Keyboard Maestro.
    • Click the + button to create a new macro.
    • Name it "Toggle Group To-dos in Things3".
  2. Add an action to execute the AppleScript:
    • Click the + button to add an action.
    • Choose Execute AppleScript.
    • Select Execute AppleScript from file.
    • Click Select... and navigate to where you saved ToggleGroupTodos.scpt.
    • Select the script file.
  3. Assign a hotkey to the macro:
    • Click the + button in the Triggers section.
    • Choose Hot Key Trigger.
    • Press the hotkey combination you want to use (e.g., Control + G).
  4. Save the macro:
    • Save the macro to make it ready for use.

Using the Macro

Now, whenever I need to toggle the "Group to-dos in the Today list by project or area" setting, I just press Control + G and the script does the job for me. No more manual navigation through the settings!

This setup is super handy for quickly changing settings in Things3, making task management even smoother.