The following may seem like a very specific tip, but it's actually applicable to anyone who needs to do stuff with lists of messages in Mail…it just requires some explanation to set up the macro, so that's what's first...
When a customer buys a license for one of our apps, I get an email with the order details. The Subject line looks like this:
Order: FOO123456-4321-02468 - Sam Sample - Moom Upgrade
Some customers have had licensing issues related to things beyond our control, but this means that I have to do the following multiple times a day:
-
Open two Mail windows. In Window 1, I display the new upgrade licenses in list view, looking something like this:
ㅤ
-
For each entry in Window 1, I have to type the user's name into a search box in Window 2. If there are two matches, all is good, it means the system worked.
-
If there's only one match, I switch to an archive app and search for the same name there. If there's no match in the archive, then this is an email I need to flag for follow-up.
I automated step three pretty easily: I just created a macro with a typed string trigger. If I type "zx" in the search box in Window 2 (at the end of the name I just searched for), the macro selects the search text, copies it, and pastes it in the search box in the archiving app. That part works great.
But I wanted to automate the tough part: The typing of the names into the search box in Window 2. You can't copy anything while viewing the message list, so that was out. And I didn't want to write a macro that would have to open and find/select text in the body of each message, as that'd be slow and fussy. After some messing about, I realized I could use the mouse location as the basis for an "area" OCR to get the job done.
Here's what I wound up with, and that can be used—with customizations for your setup, of course—for getting text out of the Subject (or other visible) line in a list of messages in Mail:
I position my mouse over the hyphen between the order number and the name, then invoke the macro. The Screen Capture box captures an area around the mouse location—a box 300 pixels wide and 20 pixels high, starting at the mouse's X location, and 13 pixels up from its Y location. Why those values?
Because that's what testing revealed worked the best for my Mail app. You'll have to experiment with the values to make sure it's capturing only what you need captured; it will vary based on your Mail font size and face, spacing, etc.
After capturing the image to the clipboard, the macro OCR's the clipboard then deletes the clipboard (no need to leave bits of graphic lying around). A search via regex action trims the name out of the OCR'd text, and puts that name on the clipboard. The rest of the macro (not shown) just switches windows and pastes the name in the search field in Window 2.
If I then need to check the archive, I just type zx
to run the other macro. When done, I move the mouse up to the next row, click the mouse to make Window 1 active, and run the macro again.
This has saved me so much typing and time! And the ability to use OCR on an area around the mouse location is something I'm sure I'll find more uses for in the future.
So thanks, KM, for saving my fingers once again!
-rob.