A recurrent issue is my inability to have KBM right click (context menu) on selected text, irrespective of the underlying app, giving me access to the services menu for that selected text.
I am currently trying to find a solution using Bear 1.9.6 , but my question would also concern other apps.
You can play with click at found image using the text highlight color, but this is a very finicky solution. Definitely not guaranteed to work everywhere.
thank you. I tried all kinds of found image options but could not find any reliable solution.
Would the master @peternlewis consider a set of actions based on "selected text" ?
macOS does not have any way to determine the location on the screen of the text selection.
I wish it did, but it does not. Some applications may reveal it via AppleScript, or Accessibility, but there is no way in general to figure out where the currently focussed text selection is.
You will need to find a different solution to your problem.
Pretty much the only thing you can do with the text selection is:
Copy
Cut (Copy & delete)
Paste (replace with the system clipboard)
Type (replace with text)
Any menu action that is available that operates on the selection (including the Services menu, which in turn can trigger a macro exported as a Text Service).
@ronald I probably totally misunderstand what you want to do. But assuming you want to open the services menu and select something, doesn't that work for you?
Macros are always disabled when imported into the Keyboard Maestro Editor.
The user must ensure the macro is enabled.
The user must also ensure the macro's parent macro-group is enabled.
System Information
macOS 10.14.6
Keyboard Maestro v10.2
** Note that this works with any frontmost application, although I've had to special-case Google Chrome due to Google's shenanigans.
This is imperfect due to the way macOS works in that the Services menu doesn't always populate the same as the Contextual menu, but it might be sufficient for your needs.
I often find it necessary to open the Services menu before selecting an item in it due to Apple's laziness.
This frequently affects keyboard shortcuts assigned with the System Keyboard prefs as well â keyboard shortcuts in the Services menu often don't work correctly until the SM has been opened once.
thanks very much for the macro !. It would be perfect, but for the fact that the item that I want to use in the context menu is Apple Translate which is curiously absent from the Services menu.
My question is beyond the scope of this forum. Would you have any idea on how to add it to the services menu ? I don't see it in the listing is sys pref.
One more detail: If the trigger (below) is used, the macro starts as soon as the mouse is released after selecting the text (with opt down). So you don't need a shortcut (eg âĽA).
I don't really know what's going on here, but I do know KM supports Swift, so I wondered if there might be a way to return the coordinates of the currently selected text?
I'll get my coat...
Oh, and I also found this, but I think it's a Cocoa (whatever that is...) thing.
You can't directly -- things have to be "wrapped up" as a Service.
But you might be able to do something similar using Shortcuts, which includes a "Translate" action. If you create it in the "Quick Actions" section it'll be added to the Services menu and the input will be the selected text when you trigger it. Something like:
I've tried that API before I'm afraid. In theory, it should be possible. In practice, it does not work reliably. It might work in one app, but not another, in one field, but not another. When I mentioned Accessibility in my original post, that was what I was referring to.
I really am a newb with Shortcuts -- but while the above works as a Services menu item, the little I understand suggests you should be able to do a more "normal" automation using the selected text and Copy-process-Paste either in a Shortcut or via KM and the "Execute Shortcut" action.