OCR every clipboard image and store result in a file Macro (v9.0.2)

OCR every clipboard image and store result in a file Macro (v9.0.2)

What a great idea!! Every image that gets placed into the SystemClipboard gets automatically OCR'd by this macro and the accumulation of text is appended to a text file, which I decided would be ~/Documents/Clipboardtext.txt. Of course you can change the file name, or you can even switch it from a file to a KM variable, but storing large quantities of text in variables has some performance impact.

OCR every clipboard image and store result in ~-Documents-Clipboardtext.txt.kmmacros (4.4 KB)

While writing this I discovered an anomaly with the OCR action. The OCR action can actually trigger an error, but the action doesn't have an option to ignore errors. That seems like an inconsistency with other KM actions. But the workaround I used was to use an IF statement that detects if the clipboard contains an image. I'm not sure if that will catch all possible errors. I would suggest that @peternlewis add an option to the OCR action to let us ignore failures. That would simplify this macro.

I can't imagine who wouldn't want this macro. Well, I suppose people who take lots of very large screenshots. A full screen screenshot can take five seconds of CPU time (on my 3 year old iMac) when processed by the OCR action. Most of my screenshots are only a fraction of the full screen and therefore will take only a fraction of a second.

Perhaps some people will want this to also log the content of regular text clipboards. I could modify this macro to include text if people ask for that addition. Or you can add that yourself.

1 Like