Joon Posted April 11, 2007 Posted April 11, 2007 (edited) 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) EndFuncReference http://msdn2.microsoft.com/en-us/library/a...office.11).aspxThanks. Edited April 11, 2007 by Joon
lod3n Posted April 11, 2007 Posted April 11, 2007 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]
lod3n Posted April 11, 2007 Posted April 11, 2007 Oh, and you need a ProgressOn command in there somewhere too. Check the help file on ProgressOn. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
Joon Posted April 11, 2007 Author Posted April 11, 2007 (edited) 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 April 11, 2007 by Joon
lod3n Posted April 11, 2007 Posted April 11, 2007 (edited) 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 April 11, 2007 by lod3n [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
Joon Posted April 11, 2007 Author Posted April 11, 2007 (edited) 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 April 11, 2007 by Joon
lod3n Posted April 11, 2007 Posted April 11, 2007 Wait, there was a bug in my code. I've fixed it - try it again now. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
Joon Posted April 11, 2007 Author Posted April 11, 2007 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Ý÷ Øë¦ë¡×®+zË9óm®+zË9ó®+zË9ó®+zË9ó®+zË9ó®+zË9ó®+zË9ó®+zË9óÄÏ®+zË9ó?r^"¯zÚ$Ymêk¡Ç¬±§íz»aÊh{VØr¢êܡ׮+zË zÛ-£]4nëDH,(mµêævzØ^¦º ©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.
lod3n Posted April 11, 2007 Posted April 11, 2007 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]
Joon Posted April 11, 2007 Author Posted April 11, 2007 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.
lod3n Posted April 11, 2007 Posted April 11, 2007 I ran it in Scite to test it. Are you fully up to date with AutoIt, beta, and Scite? [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
Joon Posted April 11, 2007 Author Posted April 11, 2007 Just updated SciTE to 3/31/2007 date one and still same problem. AutoIt version 3.2.2.0. Do we still need Beta?
lod3n Posted April 11, 2007 Posted April 11, 2007 Wouldn't hurt. I develop and test in Beta. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now