Menu exists problem

DEVONthink Pro Office has a bug that causes it to spontaneously open databases on startup. While waiting for Devon to fix this, I want to make a KM macro that will work around the bug.

My idea was to close the errant database on both quit and launch, just to be sure.

To do this, I wanted KM to look for menu File>Close Database>[datbaseName] – if it exists, the database is open and needs to be closed.

When I use a KM macro with IF [menu] EXISTS, THEN, KM can’t tell the menu exists.

I also tried adapting this appleScript but it returns false when the menu exists as well.

Suggestions? Is there a faster, more efficient way to go about this?

Thanks in advance for your help.

A small, quick suggestion. Based on advice Peter gave me regarding an issue I was having triggering menus in Lightroom (the program generates the menus dynamically), I stumbled on a work-around that might work for you.


The "Show Menu" Action apparently forces Lightroom to generate the menu. Then "Select [menu item]" Action is then able to find its target.

¯_(ツ)_/¯

1 Like

Hey @anamorph,

DEVONthink Pro Office is quite scriptable.

tell application "DEVONthink Pro"
   close databases
   close windows
   quit
end tell

-Chris

Do you know how to tell it via AppleScript to close database named "XYZ" ?

Thanks

Yep.

tell application "DEVONthink Pro"
   close database "XYZ"
end tell

-Chris

1 Like

Thank you. Strangely "close" works, but

open database "XYZ"

doesn't open the database and returns "missing value"

Do you know the correct syntax?

Thanks

Hey @anamorph

That's actually not strange at all. The database does not exist in DT's context at all until it is opened.

Here's how to go about opening a database:

set myDatabasePath to "~/Documents/DevonThink_Office/XYZ.dtBase2"
tell application "System Events" to set myDatabasePath to POSIX path of disk item myDatabasePath

tell application "DEVONthink Pro"
   
   # Uncomment to Get-Info about your database including the path (the db MUST be open).
   # properties of database "XYZ"
   
   open myDatabasePath
   
end tell

Once a database is opened DT knows how to work with it.

Do not use the absolute POSIX Path if your db file is within your user-folder.

The tilde-path (aka $HOME-path):

~/

Substitutes for this portion of an absolute-path:

/Users/your_user_name/

This notation makes your path string much less likely to break in future.

-Chris

Thanks, I’ll give that a try.

Hey @anamorph,

Remember when testing AppleScripts to use the Script Editor.app.

It makes things easier to understand when you can see the result panel and/or the Log History window.

Once you get things working THEN put them in a Keyboard Maestro Execute an AppleScript action.

-Chris