I am trying to set a hotkey for a item that's under the scripts menu item, like this:
The item doesn't show up in the selector within Keyboardmaestro. Is there a trick to select it?
I am trying to set a hotkey for a item that's under the scripts menu item, like this:
The item doesn't show up in the selector within Keyboardmaestro. Is there a trick to select it?
Hey Dave,
You need to tell us what application you’re working with…
-Chris
Hey Chris,
apologies. I saw this menu item a few times in different applications and thought it’s a common thing. This app in particular is DEVONthink
If you open the indicated "Open Script Folder" then you can get the path to those scripts. With the path, you can use a KM Execute an AppleScript action (KM Wiki) and enter the path.
You can also use FastScripts to assign shortcuts to scripts.
Hey Dave,
Script menus are not uncommon, but that doesn't mean that different apps programmed by different people do the same thing
The gentle folk at DevonTech forgot to give the script menu a name...
It only has a number (11), so Keyboard Maestro can't see it. (At least this is so in DEVONthink Pro Office.)
Peter – Please chime in if there's a way I don't know about to circumvent this.
DEVONthink Pro Office has its own schema for emplacing keyboard shortcuts in its script menu:
Move___Cmd-Ctrl-M.scpt
You may want to consider filing a bug-report with DevonTech, as this issue also affects accessibility.
-Chris
Ouch I see. Can I tell KM to select a menuitem by number? I'll see if I can somehow report this to the DEVONthink guys!
Yeah that's what I'm doing currently, but I prefer to have app-related functionality be in/part of the app, and KM separate as a layer for keybindings and automations. Plus, DT also blocks script execution if a script is still running in the background (which sometimes could take a while) to make sure things don't clash. KM doesn't do that
I think not, I tried.
We'll see if Peter has anything to add though.
-Chris
Hey Dave,
Okay, AppleScript can see the menu via System Events, so something like this will work when run from Keyboard Maestro in an Execute an AppleScript action:
----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2018/03/28 01:38
# dMod: 2018/03/28 01:38
# Appl: DEVONthink Pro Office, System Events
# Task: Activate an item in DEVONthink's script menu.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @DEVONthink_Pro_Office, @System_Events, @Activate, @Script, @Menu
----------------------------------------------------------------
tell application "System Events"
tell application process "DEVONthink Pro Office"
tell menu bar 1
tell menu 1 of menu bar item 11
tell menu item "Open Scripts Folder"
perform action "AXPress"
end tell
end tell
end tell
end tell
end tell
----------------------------------------------------------------
-Chris
Hey Chris,
Thanks a lot, that worked perfectly! Here's the final script with some last adjustments
tell application "System Events"
tell application process "DEVONthink Pro Office"
tell menu bar 1
tell menu 1 of menu bar item 11
tell menu item "My Category"
tell menu "My Category"
click menu item "Do Stuff"
end tell
end tell
end tell
end tell
end tell
end tell
Hey Dave,
You’re welcome, great, and good job.
-Chris
Selecting status menu items is difficult primarily because there is no easy way of specifying them - they don’t have names so its hard to identify them.
You can use a Click at Found Image, although even that can be difficult as they often animate or change icons based on various states. If the icon does not animate or change state (or has a known state when you want to select from it), then this can be a good solution, followed by Insert Text by Typing “Menu Name%Return%”
To click relative to an image, you use the Mouse Click action, configure it to be relative to a found image, and take a screenshot of the desired area of the screen using Command-Control-Shift-4, and paste it into the image well on the action. The image has to be unique (which includes not being visible in the action if the image is small enough not to be shrunk in the image well) otherwise Keyboard Maestro will not know where to click. The Display option in the action will allow you to see where Keyboard Maestro is matching.
I have looked into it on multiple occasions, and will no doubt look in to it again, but its a difficult problem.
Usually, the items in a scripts menu can be given keyboard shortcuts using System Preferences > Keyboard > Shortcuts > App Shortcuts by precisely specifying the name (matching capitals and punctuation) and assigning a shortcut.
That's strange. The Outlook Scripts menu (uses the same icon) does show up:
I found this just by navigating the KM Action Menu dropdown.
Also works for Script Debugger:
I prefer to use the KM Select or Show a Menu Item action (KM Wiki) rather than use scripting UI whenever I can. I find it easier and more reliable to use.
Hey Peter,
This is not a status menu item. Dave is trying to address DEVONthink Pro Office's script menu in menu bar 1.
The DevonTech folks just dropped the ball on this one – as I previously explained.
-Chris
For this purpose, the same technique of clicking based on an image will work.
I agree that DEONthink dropped the ball, but the way I handle it is just to open the Window menu using the KBM interface command and then “type” a right-arrow in KBM to move over to the “Scripts” menu and go from there to get what I want.
That's a very clever, thinking-out-of-the-box, solution.
Hey Rob,
Good man!
I use that method all the time with apps I don't have Keyboard Maestro macros set up for by using the System's built-in access to the help menu Cmd-Shift-?.
You can also use the System's built-in “Move focus to the menu bar” keyboard shortcut (Ctrl-F1 on my system) and then type-select to get to the menu you want.
See:
System Keyboard Prefs --> Shortcuts --> Keyboard --> Move focus to the menu bar
I also have a global open window menu macro, so with all the available options I'm not very far away from getting where I want to go without using the mouse.
-Chris