Hookmark's use of DEVONthink's automation to get deep links to PDFs

FYI, we at CogSci Apps have taken advantage of DEVONthink’s automation to get deep links to PDFs. Hookmark’s Copy Link function will append the current selection of the PDF. And you can use its Copy Selection and Link to copy quotes that contain a link back to the PDF/selection. The AppleScript is exposed in Hookmark’s Script Editor:

tell application id "DNtp"
    if exists (content record of current tab of window 1) then
        -- current open item
        return reference URL 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 reference URL of item 1 in selected_items
        end if
    end if
    
    -- selected group
    return reference URL of root of window 1
end tell

Screenshots and descriptions are on the Hookmark forum: :bulb: Tip: How to Copy Quotes and Deep Links to PDFs In DEVONthink - Discussion & Help - Hookmark Forum . I’ll check back here on DEVONthink forum in case anyone has comments or questions, as many Hookmark customers are also DEVONthink users. (One can use Hookmark to bidirectionally connect these two posts. That’s what I’ve done.)

Delighted that DEVONthink has the automation to do the above – for which we received many requests.

4 Likes

Instead of window 1 I would recommend to use think window 1 which is either a document or viewer window as window 1 might be any window. This simplified version should return the same results:

tell application id "DNtp"
	if exists (content record of current tab of think window 1) then
		return reference URL of (current tab of think window 1)
	else if (count of selected records) is 1 then
		return reference URL of selected record 1
	else
		return reference URL of root of viewer window 1
	end if
end tell
4 Likes

That was the code for the Get Address tab. The Get Name tab reads:

tell application id "DNtp"
    if exists (content record of current tab of window 1) then
        -- current open item
        return name 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 name of item 1 in selected_items
        end if
    end if
    
    -- selected group
    return name of root of window 1
end tell

Could that be simplified in similar fashion?
Hookmark and DT3 do work very well together.
Thanks for posting @LucB.

1 Like

Sure, basically just use name instead of reference URL.

1 Like

Thank you. We have updated the scripts. (Hookmark scripts optionally update automatically when our script server has been updated. It’s at version 323 now.)

1 Like