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.

14 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

So I had something working, similar to what Randall was describing:

The keystroke I used were ⇧alt⌘4. The difference being:

  • ⇧⌘4 let's u make a selection on screen, and save the file on desktop
  • ⇧ctrt⌘4 lets u make a selection on screen, but puts it in clipboard

So, for me it was working fine in High Sierra. Just like you see in the video./

Now that I've upgraded to Catalina, it stopped working :frowning:

I ran the same macros and it did everything the same, except for putting the selection into the clipboard. It activates the selection tool (crosshair thing), clips and drags and releases, but no "selection window" like you can see in the video. And no image in clipboard.

Can someone give me some ideas what may have caused this to stop working?

I mean, I can press ⇧ctrl⌘4 manually and whatever I select will get loaded into the clipboard, tho that's not happening when I have this command inside the macros.

The error indicators, I guess, are 1) not showing the selection window when the macros is ran (even though it shows the crosshair aiming tool. 2) nothing in clipboard after click and drag.

Is there some additional permissions that I have to allow to KM in Catalina? I've already allowed it to record my screen.

EDIT: so it's not the click nor the click+drag that's failing. It seems more likely the screenshot feature is not allowed even with the screen recording permssion given to the KM app. Possibly a common Catalina issue, from what I'm reading?

Hi - sorry to resurrect an old thread.
My questions.

  1. Is there a way to automate identifying a any of the following 3 words ? They will only occur once and there will be only one instance of it.
    2 months
    3 months
    6 months
  2. Once it determines which one it is -
    I would like to trigger a macro that is basically going to another part of the screen and clicking at a particular tab.
    I would be using this in EPIC healthcare system.