Stortcut for "Copy Page Link"

Hi I do a lot of hyperlinking of numerous discrete pdfs to a single text file for case preparation as an attorney. Can anyone please tell me the key short cut, alternatively how to make one, for “Copy Page Link” whilst on an open pdf? I assume that the paste at the other end into the text doc in DT is just the standard Mac shortcut for paste? Any assistance would be appreciated.

“Copy Page Link” appears only on a contextual menu, and it is not possible for end users to assign a keyboard shortcut to an OS X contextual menu.

For this purpose, I use this script:

-- this will put a link on the clipboard to the current page of the currently-viewed PDF in DEVONthink
-- Note that pages are numbered from 0
tell application id "DNtp"
	if the current page of think window 1 ≠ -1 then
		set the clipboard to (the reference URL of (the first item of (selection as list)) as string) & "?page=" & the ((current page of think window 1) as string)
	end if
	--else the current window is not a PDF
end tell

Copy the script. Open AppleScript Editor and paste the copied script to a new document. Compile it. Save to DEVONthink’s Script Menu or the global OS X Script menu. Scripts assigned to either script menu can be assigned a shortcut in System Preferences > Keyboard > App Shortcuts.

1 Like

Korm thanks for this. I got lost at the part “Save to DEVONthink’s Script Menu”

How do I do this? When I go to Save in in Applescript it asks me to choose a location - but how do I get it into Devonthink’s Script Menu?

regards

David

David - in DTPO - go to the Scripts menu, in the top menu bar - the first option is “Open Scripts Folder”. This will pop open a Finder window, with the location of the DTPO scripts folder, as it is stored on your Mac.

Save the Applescript that you want to use, somewhere easy to find - and then use some artful rearrangement of the two Finder windows (or Merge them into Tabs, if using Mavericks) and copy the script over to the DTPO scripts folder. You can even create a Folder called “My Scripts” or something, and place the script in there. Next time you open DTPO - under the Scripts menu, you will see the folder you just created, together with the script you just saved - click on it to run it.

Last point - one of the already existing folders is called Toolbar. Placing the script in there, will see it being added to the toolbar inside DTPO (alternatively - you might need to ‘customise’ the toolbar inside DTPO, and add it manually if it doesn’t pop up automatically - I cannot remember now whether or not that happens by default).

Save to


~/Library/Application Support/DEVONthink Pro 2/Scripts

either to that folder directly, or to a subfolder you may create in the Scripts folder

In System Preferences > Keyboard > App Shortcuts, press the “+” sign. A popover will appear. First, browse the list of applications and choose DEVONthink. Second, in the “Menu Title” box enter the name of the script file you saved – without the “.scpt” extension. Third, in the Keyboard Shortcut box type the shortcut you want to use – the shortcut needs to be different from any other shortcut in DEVONthink. For example, ⌃⌥⌘9 (control-option-command-9).

If you save the script to the Toolbar folder that @Cassady mentions will need to use View > Customize Toolbar. In the “Customize” panel you will see numerous command icons including one for your script. Drag it to the toolbar. You can customize the main toolbar, or you can customize the PDF annotation window’s toolbar, or both. You can only customize the toolbar for the window that is foremost at the time.

Thanks guys - I’ve followed your clear instructions, and now have the Copy Page Link showing in the Scripts menu. Works beautifully when I mouse click on that option BUT when I use my key combination and then paste that link back into my rtf file the link is not hyperlinked - I have to go and manually turn it blue (ie hyperlink) it. Not sure what I have done wrong…

Hmmmm…I notice on DEVONthink Pro Office 2.7.4 (released today) that after clicking a link such as the one this script makes there is a little lag before the linked document opens – maybe a second or two. I’ve not seen that before.