Hot key to move mouse cursor to where text cursor is

Hello! Long time listener, first time poster :slight_smile:

As the subject says, I’m curious if there’s a way in macOS (either globally, or in app-specific ways if needed), to trigger an automation of some kind (Keyboard Maestro, Shortcuts, BetterTouchTool, anything) - to automatically position the mouse cursor at the same spot where the keyboard focus cursor is currently located.

My use-case is, that frequently there seems to be functionality hidden under a right-click menu, contextually based on the word under the cursor. So I’m always looking to keep my hands on my keyboard (or Stream Deck), and would love to access these menu options without having to move my hands to my trackpad or mouse, target the mouse cursor to where the keyboard cursor is, and right-click.

For example, in Obsidian, if I type a word and want to add it to my custom dictionary, I’d love be able to just move the keyboard cursor over it and hit a hotkey to pop up the right-click menu, then keyboard down to choose the “Add to dictionary” option.

Or in this web form - maybe I’d like to Look up a word, or do a web Search, or any of the other myriad options under the right-click menu - and if I could do it w/o the mouse, well, I think it’d be powerful!

I’ve got a KM macro to trigger a right click at the mouse’s current position - that was easy… but I’ve not been able to find any way to move the mouse cursor to where the keyboard cursor is. I hope I’m explaining this clearly. Like, until I really thought about it and typed it out, the fact that there generally are 2 different cursors (mouse & keyboard) didn’t really even occur to me.

The best idea I have would be to use a KM Click at Found Image, where the image would be the text cursor… but it’s not a very distinct image, and it’s half the time blinking on and off, and it’s also usually obscured by the text that it’s over, so I feel like that wouldn’t be overly successful.

Anyway, thanks for any ideas. I am a developer (though only a beginner developing for apple platforms), so perhaps there’s an API that Apple has that could expose this? If so, I could build a single-purpose app just for this one thing!

Thanks for reading.

Popclip might work for you. While it is advertised as activating when selecting text with the mouse (which you are trying to avoid), there is also support for triggering it with a shortcut (assign a global shortcut to the one-line applescript). The one downside is that it does not use the built-in context menu, but you can add your own custom actions which may replicate or expand on the context menu. You can use the free trial to test it out.

So for your example use case, after you type your word, use Shift-Alt-← to select the word, then type your custom shortcut to activate Popclip, then the arrow keys to select your action and Enter to run it.

As an alternative, you may not actually need Popclip. Just set up a shortcut for each of your scripts, which all run on the selected text. Of course, that requires you to remember all of your shortcuts (and which one does what). With Popclips, you only need the one shortcut and all the actions get listed in the pop-up.

Either way, the key is to select the text. You appear to be looking for a way to work on cursor position alone. I suspect that is a dead end. However, working with selected text is a widely supported thing.

Similar to Keyboard Maestro. Desired macros are assigned the same hot key and are shown on what KM calls a conflict palette, a menu where selection is made using the keyboard.

EDIT for @Darin_Kelkhoff:

And come to think of it, the menu pops up where the cursor is!

Doesn’t seem to be easily done.
Here’s a workaround I found:
Insert a section character (§) at the cursor, then have KM (or whomever) look for that symbol, move there, erase the section symbol, then right-click.
I guess you could the same with an emoji, which might be found more reliably.

:dart:

ref

1 Like

Thanks for the suggestion! I had tried popclip long ago, and it didn’t stick for me at the time, but it may help here. I’ll give it a whirl.

Hey, that’s a good idea. In my first attempt, I’m struggling to get KM to find the emoji I picked (as I often do with smaller images), but I’ll keep at it.

Thanks!

You could also do something larger (being wary of line breaks and the like):

:dart: :dart: :dart: :dart: :dart: