Answering my own question, here is a simple “Get Address” script to get started on the path of using trello, using the same structure @Heikau used in his “Forklift” script.
It’s ugly UI Scripting, but it works.
activate application "Trello"
tell application "System Events"
tell process "Trello"
set the clipboard to ""
delay 0.3
click menu item "Copy Current URL" of menu 1 of menu bar item "Edit" of menu bar 1
delay 0.3
set theURL to the clipboard
end tell
end tell
return theURL
This returns a URL, though, so it won’t be opened in the Trello App but in a browser.
Obvious improvements would be to :
get the name of the card
open the link in trello.app
There is a trello API that could theoretically be used for this, because you can reference the card from a short link that’s embedded in the card url. I’d need to practice my regex game in applescript, then call the API. Not sure I have the time and/or the chops …
Trello does have Copy current link menu item. The URL it returns is a web URL.
If a Trello app user would test the script below and give us feedback, that would be great.
#get address
set the clipboard to ""
tell application "System Events" to tell process "Trello"
keystroke "c" using {option down, command down}
delay 0.1
repeat 10 times -- poll clipboard for ~2.5 seconds. Sometimes set x to
teh clipboard throws exception
try
set newsUrl to the clipboard
if newsUrl is not equal to "" then
exit repeat
end if
keystroke "c" using {option down, command down}
end try
delay 0.1
end repeat
set newsTitle to name of window 1
set AppleScript's text item delimiters to {"/"}
end tell
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to "/"
set reverseUrl to "" & reverse of text items of newsUrl
set text item delimiters of AppleScript to prevTIDs
set theOffset to offset of "/" in reverseUrl
if result is not 0 then
set theOffset to (count (reverseUrl)) - theOffset
set newsUrl to text 1 through theOffset of newsUrl
end if
return "[" & newsTitle & "](" & newsUrl & ")"
If anyone would like to put a feature request to the Trello folks to automate Copy Link that would be helpful. If they have an open issue tracking system or forum, that could be upvoted. It would also be better if their Copy Link returned a universal URL such that users could open the link in their app if it’s installed/preferred.
It doesn’t work as-is. Hook doesn’t recognize the window.
However this works:
For Get Adress
activate application "Trello"
tell application "System Events"
tell process "Trello"
set the clipboard to ""
delay 0.3
keystroke "c" using {option down, command down}
delay 0.3
set theURL to the clipboard
end tell
end tell
return theURL
For Get Name
activate application "Trello"
tell application "System Events"
tell process "Trello"
set theName to name of window 1
end tell
end tell
return theName
Also, I’ve sent a ticket to trello requesting automation. Let’s see!
thank you all for the feedback and scripts. I tried Trello a while back but only used the web version, with which Hook is compatible. What are the advantages of using their app?
Frankly, none that I can see. I suspect it’s a thinly disguised wrapper for the web version anyway. I get more flexibility using Trello with a chromium browser (Vivaldi is nice) and a few extensions …