Jump to content

OCR Error Handling


 Share

Recommended Posts

First I want to thank everyone in this user community for the outstanding information available in this forum. I have spent hours going through your posts and this has gotten me 95% of the way to my project goals with AutoIt.

My situation is actually quite simple and I believe the solution is as well. However, all of my searching and fiddling around have left me frustrated so I am hoping someone can help.

The screen position I am scanning will almost always contain the text I am looking for. However, occasionally it is blank and when it is blank my program just crashes. So all I need is a way to handle this error and re-try the OCR process without crashing.

Thanks in advance for any assistance!

Sleep(1000)

#Include <ScreenCapture.au3>
    
$Filename = 'C:\Users\MyName\Documents\AutoIt\images\test'

_ScreenCapture_CaptureWnd($Filename & ".tif", WinGetHandle(""),146,142,691,788, False)

$miDoc = ObjCreate("MODI.Document")
$miDoc.Create($Filename & ".tif")
$miDoc.Ocr(9, True, False)

$message = ''
For $oWord in $miDoc.Images(0).Layout.Words
    $message = $message & $oWord.text
Next

msgbox(0,"OCR Output",$message)
Link to comment
Share on other sites

Well its refreshing to see such a great attitude.

I've not got any experience in object stuff (I just havent gotten around to it yet)

But this line sprung to mind reading your post

"$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")"

It catches object errors if I understand correctly.

If you look in the helpfile under ObjEvent, you will see an example, and the forums will produsce more.

Best of luck, sorry I cant help you better.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Yes, I did find a number of posts related to that and tried to incorporate it without success. I just need to capture the error, ignore it, and continue on (looping back trying the OCR again). Simple I am sure, but after many hours of trying different things and searching the forums I am stuck.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...