borrowing and tinkering i managed to get this nice gift script to scrape stuff into Devonthink
tell application "Keyboard Maestro Engine"
set Currenturl to getvariable "SecondURL"
set Currentname to getvariable "SecondNAME"
set Currentcom to getvariable "DTcomment"
end tell
-- Create markdown record in specific group
tell application id "DNtp"
set urlName to Currentname
set urlURL to Currenturl
set urlCOM to Currentcom
create record with {name:urlName, URL:urlURL, type:markdown, source:"<link href=\"/Users/zeltak/MLT/css/prism.css\" rel=\"stylesheet\">" & "
" & "<script src=\"/Users/zeltak/MLT/css/prism.js\"></script>" & "
" & "<section class=\"line-numbers\">" & "
" & "
" & "# " & (urlName) & "
" & (the clipboard)}
end tell
issue is that after this launches and creates a note that note isnt selected i Devonthink so additional Keyboard Maestro macros cant run on it. Is there a way to specify in the Applescript to select that note or if not to send the note created UUID into the clipboard?
for anyone interested this is the full Keyboard Maestro macro:
It’s possible to select the record via AppleScript, but it depends on an open window or the script must open a new window if necessary. It’s not a good way to go, I think.
Can you tell us more about what the whole workflow should do? There might be a better way than using AppleScript and Keyboard Maestro multiple times.
Same as above, if you tell more about the why, there might be a better way.
yes sure im trying to capture selected text in an automated way
the workflow i envision is select text (ie in safari) and then issue the Keyboard Maestro macro
this will add the url to the Devonthink url field, the name of the note based on the URL name and populate a Markdown note that looks like this
<link href="/Users/zeltak/MLT/css/prism.css" rel="stylesheet">
<script src="/Users/zeltak/MLT/css/prism.js"></script>
<section class="line-numbers">
# name of note based on URL
SELECTED COPIED TEXT
i want to be able to quick move/file them (using ⌘-⌃-M) in Devonthink so i thought i would use the UUID to focus that note in Devonthink and then use Keyboard Maestro to launch that shortcut which would let me choose the destination. Does that make sense :D?
I see now that you do not tell where the record should be created.
Do you only want to be able to move the record or do you always want to move it after creation? If the latter is true then directly showing the group selector might make more sense.
This selects the record if a viewer window exists, otherwise it opens a document window, so you can always move the record if needed.
In similar scripts I always use a document window so I can directly see if everything worked. If you just select the record you might (sometimes) first have to open the preview to see the content. Also you might have a viewer window on another macOS space …
set theGroup to incoming group
set theRecord to create record with {name:"a name", type:markdown, plain text:"some text"} in theGroup
if viewer window 1 exists then
set root of viewer window 1 to theGroup
set selection of viewer window 1 to {theRecord}
else
open window for record theRecord
activate
end if