I'm just trying to build a macro that makes adding tags to a plain text file in my text editor a bit easier. The macro is supposed to move the text cursor to the first line in the document (that's where the tags are), then insert the tag (that I choose by a user prompt) and then move the text cursor back to the position where it was when I triggered the macro.
Since mouse cursor and text cursor are different, I assumed that using the "Move or Click Mouse" action (with restoring the position afterwards) wouldn't work.
I instead tried to use the "Click at Found Image" action: the macro inserts a unique text string at the original position of the cursor, then it does the tagging business, then the text cursor is supposed to return to the original position through clicking next to an image of the unique text string. I can't get this to work, because the macro never finds the image. Changing "Unique" to "Best" in the action or playing around with fuzziness don't make it work. I've had this issue with other macros using the "Click at Found Image" action as well – trying to avoid this action s much as possible...
Thanks for the interesting suggestion (I learnt new stuff), but unfortunately it doesn't solve my problem. What I am interested in is the position of the text cursor (indicated by the blinking vertical line on the screen when you type something), not the mouse cursor (usually indicated by a pointer). Your suggestion only seems to work for the mouse cursor.
Yes, exactly – they are almost never in the same place when I trigger the macro. When you work in a text editor, usually you click somewhere to start writing, and from then onwards the text cursor moves, whereas the mouse cursor stays where you started to write.
You can't really do what you want here, unless the text editor has a scripting interface.
However, if you're using an editor that supports bookmarks (I think BBEdit calls them "Jump Points?"), you could perhaps set a bookmark first, then go to the begging of the document and do your stuff, then return to the bookmark, then delete the bookmark.
Images are tricky things. Why they work sometimes and not others is hard to tell. But hey, why don't you use your editor's "Find" to return you to the spot? If you're already inserting some unique string, it shouldn't be too hard.
@JMichaelTX: It's The Archive. The developer intends to add scriptability in the future, so might have to wait a bit. This problem is not really a big deal anyway – so don't put too much effort into it! My question was more out of curiosity than necessity.
@DanThomas: I think I can't manage to get the cursor to jump out of the search field to the search result in the document (without having to rely on an image again) – but was worth a try...
Really? That sounds like a strange way to implement a Search function. I would think there's got to be a keystroke that moves you back to the document itself, or closes the search window, or something like that. But whatever. Good luck.
@DanThomas: Not as far as I can see, but will ask the developer. Thanks for your ideas!
@JMichaelTX: I sense a bit of reproachfulness in your reply. As I wrote earlier, it wasn't just curiosity – obviously it would have some benefit to make it work (otherwise I wouldn't have tried it and not put the effort of posting here into it). Little things that make the workflow a bit smoother but aren't absolutely necessary are nice – that's what's KM is mostly used for, isn't it? It was only when you offered to look into my text editor more closely when I thought that that's probably not worth it for now and you probably have bigger fish to fry.
I am chiming in here wondering if a solution has since been implemented. This would be a HUGE timesaver for me. Imagine this workflow: I am watching a coding tutorial on one screen, while attempting to follow along on another screen. To enhance this workflow, I currently use keyboard maestro to handle certain screen switching events (pause/fast forward/rewind on the video screen), and then I return my cursor back to where it was on the original screen. HOWEVER, the text cursor does not return to where it was. This would be incredibly useful for me so that I can follow along with coding videos/any videos more efficiently. I am using VSCode as my coding editor, and I'm sure it has some scripting capabilities.
I do a lot of typing while referencing video for my work as well, and the best solution I've found for controlling video playback without losing typing position isn't a Keyboard Maestro macro, but an app called Movist Pro that makes it easy to use your keyboard's media keys to pause, rewind, and fast forward video even if Movist Pro is in the background. It's not free, but it is inexpensive ($8 USD) and available on Setapp if you're subscribed to that.