I just wanted to second Sleepy's recommendation to use the OS Monterey Shortcut for OCR (if you have Monterey of course).
It's actually not that complicated and is a perfect blend of Keyboard Maestro and built-in System tools.
Sleepy worked out how to make a Monterey Shortcut Action to do the OCR work and then made "calling" that OS Shortcut Action a part of a Keyboard Maestro Macro. The bit in the the Keyboard Maestro Macro that "calls" the shortcut looks like this (just a single Keyboard Maestro Action):
That single Action runs the OS Shortcut and then saves the OCR Text back to a Keyboard Maestro Variable. The syntax here is really interesting, simple and powerful:
shortcuts run OpticalCharacterRec
The "OpticalCharacterRec" is just what I called the OS Shortcut. Which means that with this simple instruction shortcuts run Keyboard Maestro can make use of any OS Shortcut...
Of course you have to have the OS Shortcut built and ready for Keyboard Maestro. Building this shortcut has been explained by Sleepy before. But at the bottom of this post I've uploaded my version of it - just has to be unzipped and double-clicked to add it to your Shortcuts Library.
The OS Shortcut looks like this:
This OS Shortcut is telling the Mac to read a stored image (screenshot.png) and OCR the text from that image.
The Keyboard Maestro Macro that calls this OS Shortcut is -
- Getting a screenshot of an area (by you dragging the mouse).
- Saving that screenshot to the file screenshot.png
- Calling the OS Shortcut to do the heavy lifting
- Setting the result of that OS Shortcut as a Keyboard Maestro Variable
Here's the Keyboard Maestro Macro:
OCR Using OS Shortcut.kmmacros (28.1 KB)
And here is the OS Monterey Shortcut that it calls:
OpticalCharacterRec.shortcut.zip (11.8 KB)
On first run of the Keyboard Maestro Macro, this might pop up:
EDIT - a few notes:
Once you get the text into a Variable in Keyboard Maestro of course you can do anything you want with it (the last two Actions in my Macro makes it the current clipboard in plain text so it can just be pasted and displays it in a window, but you don't have to do that).
I like to have the System "shutter" sound effect and the Play Sound Action plays that sound but it's not necessary or you could play any sound.
Very cool - as OS Shortcuts sync to all your Apple Devices through iCloud you only have to set this up on a single Mac and is will then work on all your Macs if you are also syncing Keyboard Maestro.
Now you can see why Sleepy was awarded his for inventing this