I often select text (+/- images) → right click → Services → click on one of the services menu items (usually a DevonThink or Scrivener menu item)
It’s possible to do so with keyboard maestro, but it requires me to write a different macro for each app and each services menu item. There is a way to write a system wide macro with keyboard maestro (write “APPLICATION” (in caps) instead of the app name, but it is unreliable.
Is it conceivable to write an AppleScript to do so ?
thanks in advance for your time and help
the following system wide keyboard maestro action is unreliable
I didn’t do any testing on this but I think something like this as a starting point will get you to Services, assuming the first menu is the Apple menu () and the second is the named app menu (Safari, Finder, etc):
tell application "System Events"
set frontApp to (first process whose frontmost is true)
click menu 1 of menu bar item 2 of menu bar 1
select menu item "Services" of menu 1 of menu bar item 2 of menu bar 1
thank you for your time. Unfortunately, in quite a few apps, the app → services menu is different from the context menu services menu which is what I was looking for.
You might be able to use the ‘Shortcuts --> Services’ to set a shortcut in the macOS Keyboard settings, rather than using Keyboard Maestro?
I’ve just been trying to use this today and have had mixed success, but perhaps it might be worth a try.
thank you very much for the suggestion @Kaitlin
Unfortunately, the shortcuts → services route work for those situations where keyboard maestro works fine (Scrivener, safari, etc), but does not when I need it (Scrivener Scratchpad, Chrome, etc)
This will right click and select the services menu at the current mouse position:
Depends on the services menu existing and the mouse being where you want it to be.
thank you for the suggestion. This is what I was currently doing and was looking for a more elegant solution.
Your input is greatly appreciated
I access services almost exclusively via LaunchBar. You can send the selection to it by way of its “Instand Send” feature and access every applicable service by typing a part of its name or a custom set up abbreviation.
thank you. I use Launchbar, but it works for text only. I often select text + image (like a graph, etc)
As I had mentioned, I am using this method. The drawback is that the cursor must be right over the selected. Text. The challenge is to precede the right click action with a move mouse to found image action ie move mouse over selected text. Unfortunately it does not work consistently. Sometimes yes, sometimes no.
If someone has any idea about how to move mouse to selected text, it would be greatly appreciated, because it could solve the problem.
thanks again for your post
This is what I do, too. I would observe that 0.5 seconds is a long time for a menu to appear. I would encourage people to crank it down. I usually start with 0.2 seconds and either double or halve from there - depending on reliability.
For formatted text with images this might work:
- Copy the selection to the clipboard
- Invoke LaunchBar’s Clipboard history (which recognizes formatted text)
- Send the most recent entry to the service you want.
thank you. Unfortunately, the outcome is not reliable. Never works with Chrome (text only), often with Safari but not always.
You’re right. I actually changed it to .1 and that wasn’t long enough, so I defaulted it back to .5 without testing the incremental steps.
You might want to try this AppleScript instead of scripting the right click. It is going to depend on the app and what what the focussed UI element is. I don’t have DevonThink installed.
tell application "System Events"
set theApplication to first application process whose frontmost is true
set theControl to value of attribute "AXFocusedUIElement" of theApplication
perform action "AXShowMenu"
I try to avoid using Found Image actions, but sometimes they are the only hope
Is the difference not always that the context menu services are a sub-set of the app menu services list?
I’m not a super heavy user of the services menus (my key ones I have keyboard shortcuts for), to date I can’t say that I’ve ever spotted anything on a content menu list that wasn’t also on the app menu list. A quick check of a few apps and services for text and image selections didn’t throw up anything for me. I’m just surprised at such a discrepancy from Apple is all
On a 2015 15” MBP I find 0.2 works most of the time. And if it doesn’t I’ve got bigger problems.
Thanks Martin. I tried that on a couple of my macros that have a delay and 0.2 seems to work where 0.1 does not. What will I do with all of the .3 seconds free time I’ll be getting!