I can solve this request in six actions, plus the one additional action for the second macro which recalls the saved data. But I won't post my solution here for two reasons:
- You may not like my solution, since it's only 99% reliable. But let me know if you like it.
- Four of the six actions in my solution won't work for you unless you manually create the actions yourself, because they contain images, and any images I create won't work for you, because you have a different monitor size/darkmode/scaling/GUI/DPI than I do.
So what I'll do is describe my solution, and if you want, I can guide you through creating the solution yourself.
Let's say, just for example, that the app your user is using with your macro is the Safari app. (Most apps should work, but some apps contain graphic symbols in their menu names, and those apps may require a little arithmetic to get to work.) Here is how one example Safari menu looks.
If you look at the above image, you will see that the selected menu title ("File") is visually distinct from the non-selected menu titles, and that the menu item which the user is hovering his mouse over ("New Tab") is also visually distinct. We will take advantage of these facts to solve the problem.
The solution will have six actions. There will be two groups of three actions that are almost identical.
The first action will use the FindImage action to search for the location in the menu bar of the left side of the highlighted menu title. It will store the found location in a variable.
The second action will use another FindImage action to search for the location in the menu bar of the right side of the highlighted menu title.
The third action will use the OCR action, specifying Apple OCR as the reader, to read the text in that highlighted box and save the result in a global variable called MenuTitle.
The 4th, 5th and 6th actions will be identical, but will instead search for the blue bar underneath the Menu Bar. For this action, you will ignore the rightmost centimetre of the blue box, which always contains a shortcut, and depending on the app, you may have to ignore the first few millimetres of the blue box, because some apps reserve that area for graphics or checkboxes. The resulting text will be saved in a variable called MenuItem.
With all that done, you will have a second macro that the user triggers (as you say, maybe with SHIFT held) that does this:
There you go. Since Apple OCR is well over 99% reliable, this will work 99% of the time. Also, FindImage can be made to work correctly at about the same rate (99%) with correct usage.
I suppose if I were to write this macro, I would add a few extra lines of error handling, such as if the images are not found. But that's just fluff, while the main code is simply six actions, as described above.