Is there a way to move the mouse cursor to the same position as the text cursor?
I would like to control right click menus associated with the text at my text cursor. Not all right click menu options are available via an application's menu bar. Spellcheck options like Learn Spelling would be one such example.
An older StackOverflow question[1] indicates that this is not possible - but we're now 5 versions of OS X later so I'm hoping something might have changed here. Or perhaps there's an Accessibility feature now available for synchronizing the mouse and text cursors?
OSX simply doesn’t expose the contextual menu of the cursor location to a keyboard API – nor does it expose the exact position of the cursor to allow a utility like KM to move the mouse pointer to that location and perform a right-click.
Personally I think it’s nuts, but Apple plainly has never understood (or cared about) convenient keyboard access to all menu items. They’ve been way too mouse-centric over the years.
(I am well aware of the keyboard shortcuts to move focus to menu, dock, etcetera – these are all awkward compared to Windows – sad to say.)
Apple’s disdain for usability is/was one of the primary reasons why I thought the 128K Mac was junk. It was pathetic from a usability perspective. Then came an upgrade to a MacPlus, a DataDesk 101 keyboard, a RAMDisk, QuicKeys, a succession of usability utilities – and the Mac became a player.
Hmmm… If one wanted to right click at the flashing cursor could one use move and click to the image that is the flashing cursor? I know it’s not the greatest of solutions because the cursor is both very thin and it flashes so one would need pause and repeat it once, I guess…
So maybe that’s an option?
Actually one could do the following if that doesn’t work one (as a dirty work around) could do the following:
Have your macro type a “§”. Now you can search the document for the “§” character (either with images or maybe there’s a better way?). Double click on that position then right click on said position. There might be better pictures you can use (like the apple logo ?). Messy work around but it could work! (Note: I think that may be dependant on font size actually…)
@peternlewis or Anyone — Has anyone come up with a better solution than @sancarn suggested here, almost 9 years ago?
From my experience with Click at Found Image, it will absolutely depend on font, both size and color of text and background. So you would have to know the display details of the app which couldn't change or would have to be reset to a standard before searching (or maybe you could create a target image on the fly using the existing font and colors and then search for that in the target window). Is that right, or is there a way to have some flexibility in the size and/or color?
I presume that narrowing the image search to the active app window helps. I presume that if the search could be narrowed further, to something like the top third of the right half of the app window, that would be of additional help. Right? If it was possible to coerce a more precise location out of the app, could that be worth the effort?
Does the type of image being searched for help? Sancarn had two suggestions, “§” and "". The Apple logo is more dot-like while the “§” has more interior holes, making it more topologically complex. Does one type of image or the other have an advantage in the image search algorithms? Would "◎" be even better?
I'm attempting a macro to change the window size of a TextEdit window to just show only the large title at the top of the file. So my strategy so far is to add that “§” or "◎" character to the end of the first line and then find that image. I do know the font size and colors. Theoretically, I could get them from TextEdit, but I don't need to. So I can have the target image canned and ready, rather than having to create it to match on the fly.
The image match tells me the length of the title line so I can set the width of the window and delete the target symbol, “§”. I know the font size so I can set the window height based on that.
What might I do to make this simpler and smoother?
Yes. For certain situations it's amazing and 100% accurate. In macOS, there's a way to accompany the flashing text cursor with a non-flashing blue or red rectangle. It's a feature of the Voice Control / Start Listening feature in macOS. It shows up exactly 3 seconds after the text cursor starts flashing. Now, maybe a 3 second wait isn't good enough for you, but if you're just trying to write a macro that doesn't mind waiting 3 seconds, this solution is perfect.
Normally I would show you the image by taking a screenshot, but the macOS screenshot feature causes this red box to disappear as soon as you try to take a picture of it. I think all you have to do to enable this is turn on Voice Control and then turn on "Start Listening" if it isn't already on. Then you can look at it and see if it helps you.
This solution may not be right for you, but it might be right for other people, so it's still worth mentioning.
P.S. I didn't mention, but this is a solution if you use Find Image action to locate the image. I didn't test it out personally, but I'm assuming the Find Image action can see the image. If it can, then you can move the mouse to that location.