Copy the contents (not name) of a .txt item/file to the clipboard?

I am writing a Keyboard Maestro macro and need to copy the Contents (not just the name) of the selected .txt item/file in DEVONthink (not Finder) to the clipboard, but have no clue how I would go about it.
thank you very much

I won’t write the script for you - it is important to learn by doing – but the clues you need are:

-- Get the plain text content

set theContent to plain text of theRecord

-- Copy to clipboard

set the clipboard to theContent

There are a dozen or so variants of these commands, of course. These work.

3 Likes

thank you very much. I will read about AppleScript. If you know of a reference, I would be interested.

See the Automation chapter in the Help. It also includes some links to useful resources.

And don’t forget that you are not obliged to use AppleScript for that. There’s also JavaScript available.
Just use what you’re most comfortable with

2 Likes

In addition to JavaScript (good suggestion @chrillek ) embedded in a KM macro, a third option is to just use KM to simulate a user executing commands in DEVONthink’s menu. That can be in done in either four or five steps. (That’s the clue :slight_smile: )

1 Like

This is what I came up with. My problem is that I don’t know how to define (“set”) theRecord which I imagine is the selected item/file. Thank you.

tell application id "DNtp"
 set theRecord to ???
-- Get the plain text content
set theContent to plain text of theRecord
-- Copy to clipboard
set the clipboard to theContent
end tell

I have about 100 DEVONthink KM macros that I created. That was my first reflex. The problem is that I am dealing here with an item/file selected in DEVONthink, not in Finder. Thank you for your post.

@korm @BLUEFROG @chrillek
what do you think about the fact that AppleScript stops development mid 2025 ?

My problem is that I don’t know how to define (“set”) theRecord which I imagine is the selected item/file.

This is almost your answer…

set theRecord to (selected record 1)

what do you think about the fact that AppleScript stops development mid 2025

Where are you reading this?

1 Like

Apple is not ending AppleScript development. The ScriptDebugger software from Shane Stanley’s Late Night Software company is ceasing development. Sad to see him give up, but life is hard for indie developers.

2 Likes

I misread. The article was referring to script debugger as @korm indicated. thank you

1 Like

Apple has stopped development of AppleScript long ago. And they never finished JXA.
That will not change, imo. We’re saddled with two scripting languages – one stuck in the 80s of the last century, the other one not fully functional in the context of Apple scripting.

1 Like

very interesting and bizarre

In addition to the resources listed in the manual, you can also check this:

From skimming the resources listed in msteffen’s guide, I realized that Apple used to also offer their AppleScript Language Guide in PDF form—something I’ve really been wanting! But for some reason that’s not included in the documentation archive. The version available there is dated 2016-01-25…

I dug around a little and found various versions of the PDF. The most recent one I was able to track down is dated 2015-09-09, available here in the Wayback Machine. It’s nicely formatted, including an extensive document outline and a ton of internal links.

I imagine the difference between this PDF and the 2016-01-25 web version is pretty small. I like it so much better.

3 Likes

thank you very much. Very kind of you !

You’re welcome :slight_smile: The revision history says:

2016-01-25: Expanded scripting errors chapter and repeat command discussion.

So maybe check the web version for those.

1 Like