The purpose of this web page is to illustrate how you could customize Hook to integrate differently with DEVONthink.
Most DEVONthink users will be content with Hook’s default integration with DEVONthink. By default Hook identifies DEVONthink items by their
x-devonthink-item URL. Therefore, Hook’s
Copy Link command returns
However, users who primarily use DEVONthink to index folders may prefer an alternative script. When
Copy Link is called on an item in DEVONthink with that integration, the resulting URL will have the form
hook://file// rather than
x-devonthink-item://. This will make the hooks you create in DEVONthink visible when you open the same file in third party apps (a different PDF viewer, like PDFpenPro or Skim), a different text editor (like BBEdit), etc. That’s because in those other apps , Hook currently has no way of knowing what the
x-devonthink-item:// URL is. Instead, it constructs the
hook://file// URL based on the file’s path.
For current information about using Hook with DEVONthink, please see Using Hook with DEVONthink by DEVONtechnologies
Custom Get Address script for DEVONthink 3
So, if you would like Hook’s
Copy Link command to always return a
hook://file/ URL rather than
x-devonthink-item URL, then
1. Open Hook’s Preferences>Scripts tab,
2. select DEVONthink on the left,
3. click on the GetAddress tab,
4. copy and paste the following
tell application id "DNtp" if exists (content record of current tab of window 1) then -- current open item return path of (content record of current tab of window 1) end if if class of window 1 is equal to viewer window then set selected_items to selection of window 1 if (count of selected_items) = 1 then -- current selected item return path of item 1 in selected_items end if end if -- selected group return reference URL of root of window 1 end tell
Hook to New > DEVONthink
If you choose to use
hook://file/ URLs for DEVONthink items, then you should probably avoid using Hook’s
New Item > DEVONthink menu option. That’s because by default that option identifies created files using the
x-devonthink-item URL scheme.
You can delete the default
New Item > DEVONthink script. DEVONthink items would then be created with the
hook://file/ URL schemes (which is what you want); but those DEVONthink files would be created inside the DEVONthink database rather than inside a folder that is simply indexed by DEVONthink.
So if you want to use
hook://file/ URLs in DEVONthink, we recommend creating them via the other
Hook to New scripts (e.g., for .txt files or .rtf files). And:
- In Notes Preferences choose the folder that is indexed by DEVONthink. Hook will then create new files in that folder. Or,
- Move files that are created via
Hook to Newinto your indexed folder, either manually or via automation. If you want to use automation, consider Hazel which automates moving files.