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 ?
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)
tell frontApp
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
end tell
end tell
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.
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)
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.
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.
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.
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
tell theControl
perform action "AXShowMenu"
return
end tell
end tell
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
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!