ClickUp v3 Hook - GetAddress script

Hi,

I am a user of ClickUp, which doesn’t have a Hookmark integration for its desktop app. I noticed though that ClickUp.app has an URL handler registered with MacOS, and supports deep linking with the handler, and so I threw together a GetAddress script that returns a name/address markdown block. Hope it is useful to somebody:

tell application "System Events"
  tell process "ClickUp"
    set window_name to name of front window
    set AppleScript's text item delimiters to {"| #"}
    set task_name to item 1 of text items of window_name
    set task_id to item 2 of text items of window_name
    set AppleScript's text item delimiters to ""
    set addy to "[" & task_name & "](clickup://t/" & task_id & ")"
	return addy
  end tell
end tell

This can address any individual ClickUp object - normally called a Task - that has an ID. These objects, when opened in the app, present in something like a modal window addressed by a url containing their ID. Other ClickUp-isms like Lists and Spaces do not open in the modal and therefore do not work with this script.

There is one odd annoying behavior, which isn’t related to this script directly; when you open a ClickUp object (Task etc) using the protocol handler, the modal does exactly what you want BUT the page elements behind (underneath?) it do not load. I suppose this makes sense - it’s a fresh session - but a side effect is that the modal “close” button sends the user into limbo. Other links work fine, and there are plenty of them in the modal, so this is only an annoyance. I will report this as a defect to ClickUp.

Anyway, here is the full script with comments:

# This works for Task pages or anything with an id that's
# included in the foreground/modal window name.
# This means any "popup" window in ClickUp v3.
# The script depends on the window name being in the format:
#  "Task Name | #1234567" and hence if Clickup decides to change
# this format, this script will break.
# NOTE!:
#  This b0rks the v3 page navigation somewhat;
#  if you close the Task after navigating using the `clickup:`
#  protocol handler, the app just spins; so instead of 
#  using that 'X' button, just click some other nav link.
tell application "System Events"
  tell process "ClickUp"
    set window_name to name of front window
    set AppleScript's text item delimiters to {"| #"}
    set task_name to item 1 of text items of window_name
    set task_id to item 2 of text items of window_name
    set AppleScript's text item delimiters to ""
    set addy to "[" & task_name & "](clickup://t/" & task_id & ")"
	return addy
  end tell
end tell

As a personal aside, I am a VSCode CoPilot (AI) user, and it just wrote some of that docstring for me; blew me away, it just UNDERSTOOD. Scary.

1 Like

This is awesome!

Thank you very much for your contribution, @threecheese !

We will integrate it into Hookmark.

1 Like

Thanks for sharing @threecheese.