If you have Microsoft Office 2003 or Microsoft Office 2007 installed you have something called Microsoft Office Document Imaging, or MODI, which can perform OCR on Tiff and BMP files and is scriptable. Since Macro Scheduler can easily capture the screen, or a window, to a bitmap file, we can use MODI to perform OCR on the screen, or a window, to get its text. Here's how:
Code: Select all
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
Edit: If running Office 2007 MODI is not installed by default. Run your office setup and select from the installation options to install the MODI components.