OCRing for text, dependent on outcome copy file to folder

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
BlackDevilDisco
Newbie
Posts: 1
Joined: Thu Jul 29, 2010 12:45 pm

OCRing for text, dependent on outcome copy file to folder

Post by BlackDevilDisco » Thu Jul 29, 2010 12:52 pm

Hehe, yes it may sound wierd. But im trying to get Macro Scheduler to OCR my .bmp file, if it finds the text "Error", it should move the .bmp to a folder. And more advanced, if it does not find "Error", it goes to the next line and searches for "Log", and moves that file to another folder ...

From this article: http://www.mjtnet.com/usergroup/viewtopic.php?t=4147 i found my script start:

VBStart
Function DoOCR(bitmapfile)
Dim miDoc
Dim miLayout
Dim stringOut

set miDoc=CreateObject("MODI.Document")
miDoc.Create (bitmapfile)
' Perform OCR.
'You can change the mousepointer here to an hourglass or something.
miDoc.Images(0).OCR
'Change the mouse back to normal default.
set miLayout = miDoc.Images(0).Layout
stringOut=miLayout.Text
'MsgBox(stringOut)
DoOCR = stringOut
Set miLayout = Nothing
Set miDoc = Nothing
End Function
VBEND

/*
//This example OCRs entire screen

//Capture Entire Screen to bitmap
GetScreenRes>x,y
ScreenCapture>0,0,x,y,%TEMP_DIR%\~scrn.bmp

//Use OCR to get text from screen
VBEval>DoOCR("%TEMP_DIR%\~scrn.bmp"),TheText

//Display text
MessageModal>TheText

*/

//This example OCRs just the active window
GetActiveWindow>title,X,Y,W,H
ScreenCapture>x,Y,{%X%+%W%},{%Y%+%H%},%TEMP_DIR%\~scrn.bmp

//Use OCR to get text from active window
VBEval>DoOCR("%TEMP_DIR%\~scrn.bmp"),TheText

//Display the text
MessageModal>TheText


The problem as i see it is to script it to look for a specific text, and this script OCRs the whole bmp. Is it required that Macro Scheduler must ocr everything, then look for the text i define, and then proceed?

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Thu Jul 29, 2010 2:21 pm

Hi BlackDevilDisco,

This may help:

http://www.mjtnet.com/blog/2009/08/11/f ... with-modi/

MODI returns an array of the words it OCR'd and their coordinate positions within the bitmap file. In the example in the URL the script finds the coordinates of a word, moves the mouse to that location, then clicks on it. You could modify it to do other things.


Gale

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts