#include <Array.au3>
#include <ScreenCapture.au3>
;
Global Const $miLANG_CZECH = 5
Global Const $miLANG_DANISH = 6
Global Const $miLANG_DUTCH = 19
Global Const $miLANG_ENGLISH = 9
Global Const $miLANG_FINNISH = 11
Global Const $miLANG_FRENCH = 12
Global Const $miLANG_GERMAN = 7
Global Const $miLANG_GREEK = 8
Global Const $miLANG_HUNGARIAN = 14
Global Const $miLANG_ITALIAN = 16
Global Const $miLANG_JAPANESE = 17
Global Const $miLANG_KOREAN = 18
Global Const $miLANG_NORWEGIAN = 20
Global Const $miLANG_POLISH = 21
Global Const $miLANG_PORTUGUESE = 22
Global Const $miLANG_RUSSIAN = 25
Global Const $miLANG_SPANISH = 10
Global Const $miLANG_SWEDISH = 29
Global Const $miLANG_TURKISH = 31
Global Const $miLANG_CHINESE_SIMPLIFIED = 2052
Global Const $miLANG_CHINESE_TRADITIONAL = 1028
Global $oMyError = ObjEvent("AutoIt.Error","OCRErrFunc")
_ScreenCapture_Capture(@ScriptDir & "\OCR_Test_Img.jpg", 50, 60, 600, 600, False)
$aArray = _OCRGet(@ScriptDir & "\OCR_Test_Img.jpg", $miLANG_ENGLISH)
ConsoleWrite(@error)
_ArrayDisplay($aArray, "OCR Result")
For $i = 1 To UBound($aArray)-1
ConsoleWrite($aArray[$i] & @CRLF)
Next
Func _OCRGet($sImageFile, $iLang=9)
Local $aArray[1000], $oWord
Local $oMODI_Doc = ObjCreate("MODI.Document")
If Not IsObj($oMODI_Doc) Then Return SetError(1)
$oMODI_Doc.Create($sImageFile)
If @error Then Return SetError(2)
$oMODI_Doc.Ocr($iLang, True, False)
If @error Then Return SetError(3)
For $oWord In $oMODI_Doc.Images(0).Layout.Words
$aArray[0] += 1
$aArray[$aArray[0]] = $oWord.Text
Next
ReDim $aArray[$aArray[0]+1]
Return $aArray
EndFunc
;------------------------------ This is a COM Error handler -----------------------------
Func OCRErrFunc()
Local $HexNumber = Hex($oMyError.Number, 8)
Msgbox(0,"COM Error Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $oMyError.Description & @CRLF & _
"err.windescription:" & @TAB & $oMyError.WindDescription & @CRLF & _
"err.number is: " & @TAB & $HexNumber & @CRLF & _
"err.lastdllerror is: " & @TAB & $oMyError.LastDllRrror & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.ScriptLine & @CRLF & _
"err.source is: " & @TAB & $oMyError.Source & @CRLF & _
"err.helpfile is: " & @TAB & $oMyError.HelpFile & @CRLF & _
"err.helpcontext is: " & @TAB & $oMyError.HelpContext)
SetError(1) ; to check for after this function returns
Endfunc