Created
October 11, 2019 15:43
-
-
Save wljgo/1868e78bbf60e7a4401f4ed6ce8d923c to your computer and use it in GitHub Desktop.
Applescript code for "Get Adress" Hook - Things Integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tell application id "com.culturedcode.ThingsMac" | |
| set _id to null | |
| set n to count of selected to dos | |
| if n = 1 then | |
| set _id to id of item 1 of selected to dos | |
| else if n = 0 then | |
| set _inbox to {id_name:"TMInboxListSource", |id|:"inbox"} | |
| set _today to {id_name:"TMTodayListSource", |id|:"today"} | |
| set _anytime to {id_name:"TMCalendarListSource", |id|:"anytime"} | |
| set _upcoming to {id_name:"TMNextListSource", |id|:"upcoming"} | |
| set _someday to {id_name:"TMSomedayListSource", |id|:"someday"} | |
| set _logbook to {id_name:"TMLogbookListSource", |id|:"logbook"} | |
| set _trash to {id_name:"TMTrashListSource", |id|:"trash"} | |
| set _list to {_inbox, _today, _anytime, _upcoming, _someday, _logbook, _trash} | |
| set _name to name of item 1 of windows | |
| set _id to id of list _name | |
| if exists area _name then | |
| set _start to (count "THMAreaParentSource/") + 1 | |
| set _lenght to count (_id) | |
| set _id to text _start thru _lenght of _id | |
| else if exists contact _name then | |
| set _start to (count "THMContactParentSource/") + 1 | |
| set _lenght to count (_id) | |
| set _id to text _start thru _lenght of _id | |
| else | |
| repeat with _item in _list | |
| if id_name of _item = _id then | |
| set _id to |id| of _item | |
| end if | |
| end repeat | |
| end if | |
| else | |
| set proj to project of item 1 of selected to dos | |
| repeat with todo in selected to dos | |
| if proj is not project of todo then | |
| return | |
| end if | |
| end repeat | |
| set _id to id of proj | |
| end if | |
| if _id is not null then | |
| set todo_url to "things:///show?id=" & _id | |
| end if | |
| todo_url | |
| end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment