hello there, i'm trying the ocr script as well and i've found a problem that i'm not able to avoid
If the captured part of the screen doesn't contain any text to ocr, the script stops himself with an error.
C:\Programmi\AutoIt3\Examples\OCR SCRIPT.au3 (52) : ==> The requested action with this object has failed.:
$oDoc.Ocr(16, True, False)
$oDoc.Ocr(16, True, False)^ ERROR
>Exit code: 1 Time: 24.917
this is the code that i'm using
#include <ScreenCapture.au3>
while 1
FileInstall( "c:\programmi\MiniCap\MiniCap.exe", @SYSTEMDIR & "\" )
$sTargetImage = "D:\programmi\ocrtesto.gif"
$sTargetTitle = "Last Land"
WinWaitActive( $sTargetTitle )
sleep (100)
;Capture the target by position
$aPos = WinGetPos( $sTargetTitle )
$sSwitches = ' -save "' & $sTargetImage & '"'
$sSwitches &= ' -captureregion ' & 310 & ' ' & 640 & ' ' & 634 & ' ' & 683
$sSwitches &= ' -exit'
RunWait( @COMSPEC & ' /c minicap.exe ' & $sSwitches, "", @SW_HIDE)
;image magick part
$oMagic = ObjCreate("ImageMagickObject.MagickImage.1")
$ret = $oMagic.Convert("d:\programmi\ocrtesto.gif", _
"-black-threshold", "88%", "d:\programmi\ocrtesto1.gif")
sleep (1000)
;~ $img = ObjCreate("ImageMagickObject.MagickImage.1")
;~ $ret = $img.Convert("d:\programmi\ocrtesto.gif", _
;~ "-resize", "1024x768", _
;~ "d:\programmi\last land\ocrtestonew.gif")
;~
;~ $sTargetImage = "d:\programmi\ocrtestonew.gif" ;immagine da scansionare ingrandita
;~ $sTargetImage1 = "d:\programmi\ocrtesto.gif" ;immagine da scansionare originale
;WinWaitActive( "Gimp" )
$sTargetImage = "D:\programmi\ocrtesto1.gif"
$sTargetText = _OCRGetText( $sTargetImage )
tooltip ($sTargetText, 0, 900)
;Display the results
;Msgbox( 0, @SCRIPTNAME, "Results of OCR:" & @LF & $sTargetText )
If StringInStr($sTargetText, "built in") Then
sleep (2000)
Send("{ENTER}Salve{ENTER}") ;check if the built in words are in the image
EndIf
WEnd
Func _OCRGetText( $Image )
Local $oDoc = ObjCreate("MODI.Document")
$oDoc.Create($Image)
If @ERROR Then Return SetError(1)
$oDoc.Ocr(9, True, False) ;ENGLISH = 9
If @ERROR Then Return SetError(2)
Return $oDoc.Images(0).Layout.Text
$oDoc = 0
EndFunc