OCR -- User-Selected Area Macro (v9.0.1)

Use Case

  • Make it easy to OCR any selected region of your screen

MACRO:   OCR -- User-Selected Area by @ccstone

This macro was written by Chris @ccstone, who shared it with me. Since Chris has been away for a bit on personal business, I got his permission to upload this for all to enjoy.

~~~ VER: 1.0    2019-08-26 ~~~
Requires: KM 9+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

OCR -- User-Selected Area.kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


How To Use

  1. Display the window/screen that contains the image you wish to OCR
  2. Trigger this macro
  3. Select the area for the screencapture.
  4. OCR results are put on Clipboard

Macro Setup

  1. Assign a Trigger to this macro.
  2. Move this macro to a Macro Group that is only Active when you need this Macro. In this case it is best for this MG to be in a Global group so that it is always active.
  3. ENABLE this Macro, and the Macro Group it is in.

10 Likes

I just have to pipe in to say...

This macro is incredible!! Who even knew this kind of thing was possible? Not me! :nerd_face::+1:t3:

Thank you, thank you, thank you!!

John

Is possible without new lines?

Sure. You can add a Search and Replace Action:
SEARCH FOR:
\R

REPLACE WITH:
𝍖
where 𝍖 is a space, or any other character you'd like to use.

That's cool.
Thanks.

Hello, It seems does not work for me.

That's because you are searching for a "String", and it should be using a "Regular Expression":

image

1 Like

Thanks, it's work now.

1 Like

A post was split to a new topic: How Do I Use Move Mouse Action with Screen Capture?

Hello JMTX,
I hope you are doing well. You had mentioned that you were very busy.
Your macro is extremely useful. I use it all the time. Instead of OCR the user selected area, is it possible to define user selected area→ print user selected screencapture
thanks

I use these three actions:

The 1st one deals with the case when a word is broken up into two parts and connected with a hyphen:

. . . end of one li-
ne beginning of another line . . .

The 2nd removes all other line breaks.

The 3rd action replaces two spaces "𝍖𝍖" with a line break. This is to deal with the paragraph marks that were in the original text. After the 2nd action, where the paragraph mark was in the original text, they will be two spaces "𝍖𝍖". Adding the third action will restore the paragraph mark.

I use it to OCR some PDF texts. Many PDFs on archive.org are not well OCRed. The text is unintelligible, filled with all sorts of random characters. This macro has served me well.

When I'm dealing with languages I can't read smoothly, I add a Google Translate action:

https://translate.google.com/?hl=en&tab=TT#view=home&op=translate&sl=auto&tl=en&text=%Variable%Parameter%

My OCR German and translate look like this:

1 Like

Perhaps I'm an idiot (and I am new to KM), but I am not understanding how this works or how to make it work.

  1. When I press shift/command/4 my mac allows me to select a rectangle of my screen to capture. The result is a new image file on my desktop.
  2. I would like this action itself to trigger the OCR to clipboard macro so that my next paste would place the OCR'ed text into what ever text field I am editing.

How do I set the trigger of the of the above macro to a region of screen capture?

This macro runs in edit mode when I click on the run icon. But when I press the keyboard shortcut I have set, nothing happens. What Am I doing wrong?

Look at the very first Macro in this thread, written by @JMichaelTX. This does exactly what you are asking for. Just set your own hotkey shortcut (Trigger) for it. This Trigger could even be ⇧⌘4 as you are saying you want - although that is not a good idea as it will override the built-in Mac shortcut for copying a selection of screen to the Clipboard.

Hey Randal,

Welcome to the forum!   :smile:

Make sure the macro you imported and the macro group it is in are enabled.

All macros are disabled by default when imported, although different circumstances may disable the macro itself or the macro group containing it.

If you haven't read these they're worth a couple of minutes of your time.

Tip: How Do I Get The Best Answer in the Shortest Time?

How to Post Your Macro to the Forum

-Chris