DTPOSimple Script: New group with selection

I need a simple script, but don’t know how to make it real.

I would like to create a new group with the selection as a title. Let’s say I highlight a few words in Safari. I would like these words to be the name of my new group.

Do you know how can I make this happen?

It’s easy to do this for Safari but this approach won’t work for other applications:


tell application "Safari" to set this_selection to do JavaScript "unescape(getSelection())" in document 1
if this_selection is not "" then
	tell application "DEVONthink Pro" to create record with {name:this_selection, type:group}
end if

Oh! It’s the type:group thing!

Thanks for you immediate reply!

DTP support rules! I’ve been always recommending DTP to my friends and colleagues because of your excellent work.

Too bad this doesn’t work in other applications. I would be very much delighted to make it work for EndnoteX or text having copied in the clipboard?? Any suggestions for that?

You could try this (while DT Pro is not the active application):


tell application "System Events"
	keystroke "c" using {command down}
	delay 0.5
	set theSelection to the clipboard as string
end tell

That was something more than immediate :smiley:

It’s great! thanx!!!