DevonThink Ratings Menu

I'm trying to create Macros for the DevonThink Ratings menu and also the Labels menu. Ratings is a submenu found under data. What kills me is I can't find a way to invoke the stars themselves.
Screen Shot 2021-11-24 at 5.07.29 PM
I even tried recording a macro just to show me what KM sees. KM sees Data -> Rating -> blank

Colour me confused
Mark

1 Like

If the app doesn't have keyboard shortcuts for those ratings, then the next consideration is whether the app support AppleScript. You can open the app using the Script Editor app and see if there's support for changing the rating using AppleScript. If that doesn't work then we may need to use KM's mouse click actions. How important is this that you don't use the mouse for the solution? If you're just trying to get this macro to run when you aren't on your Mac, then I guess speed and mouse issues aren't too important.

1 Like

Hi @mlevison, the AppleScript is from the DEVONthink forum:

 -- Import helper library
    tell application "Finder" to set pathToAdditions to ((path to application id "DNtp" as string) & "Contents:Resources:Template Script Additions.scpt") as alias
    set helperLibrary to load script pathToAdditions


    -- Get the selection
    tell application id "DNtp" to set thisSelection to the selection

    -- Error handling
    if thisSelection is {} then error localized string "Please select a document or group, then try again."
    if (length of thisSelection) > 1 then error localized string "Please select only one document or group, then try again."

    tell application id "DNtp"
    	set thisItem to first item of thisSelection
    	set rating of thisItem to 3
    end tell

2021_11_24_Support_1

I have created a macro group for you. After entering the shortcut, you can click on your ratings with the mouse.

DEVONthink Rating Macros <4084 211124T234437>.kmmacros (286,4 KB)

If you prefer to work only with the keybaord, then you must enter the shortcut once in this macro and then confirm your selection with 0 to 5. Of course you can also replace the numbers with letters.

DEVONthink Rating:Key Macros <2148 211124T234850>.kmmacros (288,0 KB)

@mlevison Here is a macro suggestion for using labels.

DEVONthink Label Macros <5CDA 211125T002151>.kmmacros (267,0 KB)

Here, too, just enter the shortcut and select the labels with the initial letter (R = Red).

Since I avoid shortcuts myself as much as possible, I have set up the Rating as well as the Label macro group as Sup macro groups (Sub palettes).

Thanks, AppleScript and I have a poor working relationship. Magically it won't do what I expect and then spend days staring at it trying to figure out the why :-). The irony is that I'm recovering software developer.

In this case I can prove script got invoked - I added a text display and it appears so the function is being invoked. From there I don't where to look to see what what failed.

@mlevison does this mean that my macros (AppleScripts) do not work for you?

Sad, but true.

@mlevison there are a few possibilities where it can hang :wink:

In order for KM to run AppleScripts and System Events, you need to run

System Events.app
AppleScripts utility.app

in System Preferences - Privacy - Accessibility.

(please don't wonder, I'm using a german speaking macOS).

Please also check if you have given KM all permissions:

@appleianer Thanks for the help. MacOS in German - I just assume its a side effect from long term use of DevonThink. It's developed in German. I wonder if that will happen to me in a few years.

The bizarre. Neither System Events or AppleScripts Utility were in the accessibility list. Nor do I know where to find them. However searching for them caused me to find: Avoiding AppleScript Security and Privacy Requests – Scripting OS X

Which helped me discover:

Cursor_and_Security___Privacy_and_DevonThink_Ratings_Menu_-Questions___Suggestions-_Keyboard_Maestro_Discourse

As soon as I checked that it worked. Now of course the only problem is where to record this so I don't forget the next time I need to automate something simple.

Thanks for the help.

@mlevison I didn't know that at the beginning with KM either. Look here:

Video

@mlevison that with the documenting could look like this :wink:

Action Note:

Macro or Macro Group Note:

What I can recommend to you is to make notes in a text editor of your choice and then put a link to it in the KM Comment action.

1 Like