I’d like to be able to activate the content area with a menu item or a shortcut so I can edit a (markdown) text file with, for example, Keyboard Maestro based on the selected file. I haven’d found a way to do that unfortunately.
Welcome @reinierladan
As mentioned on Twitter, this is done with Control-Tab(and Shift-Control-Tab for reverse cycling through the elements). But again this depends on the number of panes and bars showing. For example, if the Tags bar is showing, that will be part of the cycle.
What are you trying to do to the Markdown file?
In automation, you don’t replicate mechanical actions, like click this and type that.
What I, for example, like to do is create a new Markdown file and paste a template with my own custom variables filled in (based on a Keyboard Maestro script) as the contents of that file.
And I’m not sure what you mean by “In automation, you don’t replicate mechanical actions, like click this and type that”, it’s pretty common practice to invoke typing stuff in a Keyboard Maestro macro. And what I use all the time is that I, for example, let Keyboard Maestro select a menu item from an app. This is not done by moving the mouse cursor ‘mechanically’ but KM can access all the menu items of all the apps that are running. This way I can chain common actions I do in a certain app.
like to do is create a new Markdown file and paste a template with my own custom variables filled in (based on a Keyboard Maestro script) as the contents of that file.
This is also possible to do with a template in DEVONthink. See Help > Documentation > Automation > Smart Templates.
I have more use cases then just populate a new file. So in short: get the focus on the content window is not easily and predictably possible in DEVONThink?
Try this: ⌃⌘P then ⌃⌘X
The focus will land on the text area of the MD file in Source mode.
Or use an applescript
tell application id "KM*E"
set theText to ""
set theText to value of variable "{name of the variable your are using in km}"
end tell
tell application id "DNtp"
set theRecord to (content record of think window 1)
set the plain text of theRecord to theText
end tell
Note: this will override whatever text is already there.
You could also use this option below which is safer:
tell application id "KM*E"
set theText to ""
set theText to value of variable "{name of the variable your are using in km}"
end tell
tell application id "DNtp"
set theRecord to (content record of think window 1)
set thePlainText to the plain text of theRecord
set the plain text of theRecord to thePlainText & theText
end tell
This UI script should set the focus on a new markdown records content (in list view).
-- Set focus on new markdown record (in list view)
activate application id "DNtp"
tell application "System Events"
tell process "DEVONthink 3"
try
set focused of text area 1 of scroll area 1 of splitter group 1 of tab group 1 of splitter group 2 of splitter group 1 of window 1 to true
on error
try
set focused of text area 1 of scroll area 1 of splitter group 1 of tab group 1 of splitter group 1 of splitter group 1 of window 1 to true
end try
end try
end tell
end tell