Jump to content

Having problem displaying MODI OCR Progress Event


Joon
 Share

Recommended Posts

Here is my script and I am having problem with MODI OCR Event. I get the OCR text fine, just unable to display Progress during the OCR.

Dim $objMODI, $OCREvent
Dim $Progress = 0
Dim $Cancel = False

$objMODI = ObjCreate("MODI.Document")
$OCREvent=ObjEvent($objMODI,"ModiEvent_","OnOCRProgressEvent") 

$objMODI.Create (@ScriptDir & "\TEST.TIF")
$objMODI.OCR


$Page = 1
For $image in $objMODI.Images
    MsgBox(0,"Page: " & $Page,$image.Layout.Text) 
    $Page += 1
Next


$OCREvent = 0
$objMODI = 0
Exit

Func ModiEvent_OnOCRProgress(ByRef $Progress,$Cancel)
    ProgressSet ($Progress)
EndFunc

Reference

http://msdn2.microsoft.com/en-us/library/a...office.11).aspx

Thanks.

Edited by Joon
Link to comment
Share on other sites

Autoit event handlers cannot take parameters by ref. When an event fires, the parameters are copied, and passed to the event handler. I wish it were not so, but it is. (I'd really really appreciate it if someone could prove me wrong on this though!)

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

How is this event differ from IEEvent_ProgressChange on ObjEvent example on help file?

Adding ProgressOn to the example for ObjEvent made example script run, but still this does not fix my problem.

I think, I'm not even capturing the Event.

Thank you.

Edited by Joon
Link to comment
Share on other sites

Well, you might be exiting before it finishes. Why not make the script wait until you exit it, and capture all events so you can see what events are actually firing when. Make sure you run the following in SciTE:

Dim $objMODI, $OCREvent
Dim $Progress = 0
Dim $Cancel = False

$objMODI = ObjCreate("MODI.Document")

$OCREvent=ObjEvent($objMODI,"ModiEvent_")
Func ModiEvent_($eventName,$value1,$value2)
    ConsoleWrite("Event: " & $eventName & ", Value1: " & $value1 & ", Value 2: " & $value2 & @crlf)
EndFunc

HotKeySet("{esc}","quitter")
func quitter()
    $OCREvent = 0
    $objMODI = 0
    Exit
EndFunc

$objMODI.Create (@ScriptDir & "\TEST.TIF")
$objMODI.OCR

$Page = 1
For $image in $objMODI.Images
    MsgBox(0,"Page: " & $Page,$image.Layout.Text)
    $Page += 1
Next

while 1
    sleep(1000)
WEnd
Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

I didn't capture any event at all. When I put that in Example, it capture all Event for IE.

Maybe OnOCRProgressEvent is not compatible with AutoIt?

Anyway, it was nice know that you can capture all event through that way. This will help many problems down to the row.

Thanks.

Edited by Joon
Link to comment
Share on other sites

Now, it's working with another problem...

$objMODI = ObjCreate("MODI.Document")
$OCREvent=ObjEvent($objMODI,"ModiEvent_") 
Func ModiEvent_($eventName,$value1,$value2)
    ConsoleWrite("Event: " & $eventName & ", Value1: " & $value1 & ", Value 2: " & $value2 & @crlf)
EndFunc

$objMODI.Create (@ScriptDir & "\TEST.TIF")

ProgressOn("OCR","Please wait...")
$objMODI.OCR


$Page = 1
For $image in $objMODI.Images
;~  MsgBox(0,"Page: " & $Page,$image.Layout.Text) 
    $Page += 1
Next

ProcessClose("OCR")

$OCREvent = 0
$objMODI = 0
ConsoleWrite("EXIT" & @LF)
Exit

Func ModiEvent_OnOCRProgress($Progress,$Cancel)
    ConsoleWrite("Progress : " & $Progress & @LF)
    ProgressSet ($Progress)
EndFuncoÝ÷ Øë­¦ë¡×®+9óm®+9ó®+9ó®+9ó®+9ó®+9ó®+9ó®+9óÄÏ®+9ó?r^"¯zÚ$Ymêk¡Ç¬±§íz»aÊh{VØr¢êܡ׮+zË zÛ-£]4nëDH,(mµêæv­zØ^¦º ­©i×^vX§zÚºÚ"µÍ[È]Z]
B   ÌÍÓÐÔ][H   ÌÍÛØSÑHHPÛÛÛÛUÜ]J ][ÝÑQIÌÌÎÉ][ÝÈ  [ÈB^][[

and this is what I get.

-- cut --
Event: OnOCRProgress, Value1: 60, Value 2: 0
Event: OnOCRProgress, Value1: 60, Value 2: 0
Event: OnOCRProgress, Value1: 80, Value 2: 0
Event: OnOCRProgress, Value1: 100, Value 2: 0
DIE!

hang.

So I guess, I need to find out how to release the object.

Link to comment
Share on other sites

Here, I made one that actually works:

global $objMODI = ObjCreate("MODI.Document")
ProgressOn("OCR","Please wait...")

$OCREvent=ObjEvent($objMODI,"ModiEvent_")

$objMODI.Create (@ScriptDir & "\TEST.TIF")
$objMODI.OCR
For $oWord in $objMODI.Images(0).Layout.Words
    ConsoleWrite($oWord.text & " ")
Next

Func ModiEvent_OnOCRProgress($Progress,$Cancel)
    ProgressSet ($Progress)
    if $progress = 100 Then
        Exit
    EndIf
EndFunc

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Your did the samething as mine. Where it hangs after Exit command. Well... I think it's something to do with SciTE problem. Both yours and mine work fine Compiled or Run Script via Right click on Au3 file.

Thanks. It helped alot. :shocked:

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...