Jump to content



Photo

Real OCR in AU3 - in a few lines.


  • Please log in to reply
132 replies to this topic

#61 climberman

climberman

    Seeker

  • Active Members
  • 14 posts

Posted 30 June 2008 - 05:47 AM

Hey I'm having some trouble.

The first error I got for undeclared variables and found them in here after running the check

$Viewer = GUICreate ( "Embedded MODI Viewer", 640, 580,(@DesktopWidth-640)/2, (@DesktopHeight-580)/2 , _                     $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)


I added Dim statements so at least it would run and it did. It read the file too which was excellent but here's the problem. It froze when it opened the modi window and i had to force quit that window so that the results would pop up.

Did something go wrong with the autoit installation with those variables missing or something like that? Maybe a better question is what the WS_ variables are

All help is appreciated. I'm running Vista i that makes a difference, Office 2003.





#62 ptrex

ptrex

    Universalist

  • MVPs
  • 2,399 posts

Posted 30 June 2008 - 06:59 AM

@climberman

Maybe if you add

#include <WindowsConstants.au3>


This might get you going

regards

ptrex

#63 climberman

climberman

    Seeker

  • Active Members
  • 14 posts

Posted 30 June 2008 - 11:50 PM

@climberman

Maybe if you add



This might get you going

regards

ptrex

Yes that absolutely did the trick. AutoIt is a bit different than what im used to pragramming mathematical stuff but your posts are very helpful. If I'd read up on the function maybe I would've caught that mistake.

Anyways, I threw in my own twist as a test to capture a window and it worked with your script. I downloade a vista sidebar gadget to see my mouse coordinates since I can't think of a good way to see that on the fly without writing something myself and taking way too long to get it to work.

I plan to replace my addition with a specific region screen capture. After seeing the offshoot with minicap.exe, this way seems much better, plus the minicap thing didn't work for me. so thx ptrex and here's some code for anyone else interested.

;Wait for the window so that we capture it     $sTargetImage = "C:\Users\Brian\Desktop\OCR_tgt.jpg"     $sTargetTitle = "Untitled - Notepad"     WinWaitActive( $sTargetTitle )     _ScreenCapture_CaptureWnd($sTargetImage, WinGetHandle($sTargetTitle))


The built in screen capture function needs to be included. O and the mouse can be turned off but i didn't bother since this was a test

#64 Pain

Pain

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 627 posts

Posted 30 June 2008 - 11:57 PM

use AutoIt Window Info to get mouse coordinates etc.

#65 C2C

C2C

    Adventurer

  • Active Members
  • PipPip
  • 108 posts

Posted 01 July 2008 - 12:47 PM

Can anybody confirm this working on Vista Ultimate x86 with Office 2007 ?
----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win

#66 Markos

Markos

    Seeker

  • Active Members
  • 33 posts

Posted 06 July 2008 - 05:05 PM

Just spent half a day on getting this to work.
So for ppl having the same problems as me:

#1: doesn't work on x64 v. of autoit -> use either unicode or ANSI v. of autoit
#2: When I installed my Office 2007 I unchecked some features of it. When I used full instalation, this started to work.
Posted Image

#67 Skrip

Skrip

    Psychonaut

  • Active Members
  • PipPipPipPipPipPip
  • 2,340 posts

Posted 07 July 2008 - 12:36 AM

Does not work on Office 2007.

We're trapped in the belly of this horrible machine.And the machine is bleeding to death...


#68 duckling78

duckling78

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 07 August 2008 - 07:53 PM

Func OCR_Region($x,$y,$width,$height)ƒo݊÷ ØZèšÚòŠx-†+ºw-ЉèºÙšÉ·­…êZ­©žµêïj¸šnW¬².•ÖÞ²‰ž¶§‚X¤zØb²)ìµæjëhŠ×6Func OCR_Region($left,$top,$right,$bottom)


The "$width" and "$height" does not seem to be correct when testing this function out with Office 2003 SP3 installed.

Sorry if this was already covered somewhere. Thanks for the functionality! :P

#69 climberman

climberman

    Seeker

  • Active Members
  • 14 posts

Posted 08 August 2008 - 03:20 PM

So far I've been having great success with this, but now have encountered a strange problem.

I have the OCR in several different functions.
The first time, it executes with a certain file just fine and exits the function.
The next time, it uses a different image just fine but in a seperate function and the exits the function.
The third time, it goes back into the same function and whether it reads a different file or not, the OCR fails, even if it was the same image as before but only renamed.
I tried throwing in a close statement to the document but it didn't give a fix.
Any ideas?

#70 Michel Claveau

Michel Claveau

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 352 posts

Posted 08 August 2008 - 03:42 PM

Hi, Firestorm!

You said:

Does not work on Office 2007.


But, on my Vista-Ultimate + MS-Office-2007, it work OK.

Edited by Michel Claveau, 08 August 2008 - 03:43 PM.


#71 climberman

climberman

    Seeker

  • Active Members
  • 14 posts

Posted 08 August 2008 - 09:52 PM

So far I've been having great success with this, but now have encountered a strange problem.

I have the OCR in several different functions.
The first time, it executes with a certain file just fine and exits the function.
The next time, it uses a different image just fine but in a seperate function and the exits the function.
The third time, it goes back into the same function and whether it reads a different file or not, the OCR fails, even if it was the same image as before but only renamed.
I tried throwing in a close statement to the document but it didn't give a fix.
Any ideas?


Sorry for this earlier post, I just cleaned up some of the code that seemed like extra junk and it took care of the problem.

#72 Sand

Sand

    Seeker

  • New Members
  • 2 posts

Posted 18 August 2008 - 07:54 AM

Hello

it's just me or when i give a small areas to OCR i get COM Error ?
for example OCR_Region (19,619,49,707) and i get the COM Error is this normal ?

Here is my function

Func OCR_Region($x,$y,$x1,$y1)     Const $miLANG_ENGLISH = 9     $file_name = "C:\VRT_Temp.png"     _GDIPlus_Startup ()     _ScreenCapture_Capture ($file_name, $x,$y, $x1,$y1, False)     Dim $miDoc = ObjCreate("MODI.Document")     $miDoc.Create($file_name)     $miDoc.Ocr($miLANG_ENGLISH, True, True)     Dim $str = $miDoc.Images(0).Layout.Text         FileDelete($file_name)         _GDIPlus_ShutDown ()         Return $str     EndFunc

Edited by Sand, 18 August 2008 - 07:56 AM.


#73 APPLEEATER

APPLEEATER

    Wayfarer

  • Active Members
  • Pip
  • 51 posts

Posted 31 August 2008 - 09:39 PM

Is it possible just to get the ORC part of office?
because i do not want to have to install Microsoft Office to use this...
thanks

#74 zhuzb

zhuzb

    Seeker

  • Active Members
  • 5 posts

Posted 01 September 2008 - 03:25 AM

Very good Script!

#75 ptrex

ptrex

    Universalist

  • MVPs
  • 2,399 posts

Posted 01 September 2008 - 08:16 AM

@APPLEEATER

I don't think this is possible ?

Maybe you can try to install Office Web Components only and test if it is included in that ?

@zhuzb

Thanks

Regards

ptrex

#76 ofLight

ofLight

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 280 posts

Posted 03 September 2008 - 01:00 PM

@APPLEEATER


I mainly use this OCR within VM's, and dont want the overhead of Office on every instance. So i just install MODI. You can just download the Microsoft Office Document Imageing from MSDN, im not sure if this is the exact link for wuttever OS you use. MSDN LINK

EDIT: wrong link, lemme see if i can find the one where i downloaded mine.

EDIT2: I think Ptrex is correct, you cant download it through MSDN seperate anymore??? or atleast I cant seem to find the install package, only the reference. I have looked through my backups and found the .dll's I was installing, the main one I think you want is MDIVWCTL.DLL.

Edited by ofLight, 03 September 2008 - 01:46 PM.

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Posted Image


#77 LinuZ

LinuZ

    Adventurer

  • Active Members
  • PipPip
  • 100 posts

Posted 03 September 2008 - 08:17 PM

Is there no way to do this without any programs that cost?

#78 ovideo

ovideo

    Seeker

  • Active Members
  • 19 posts

Posted 12 September 2008 - 12:30 AM

oh hi. great work on this, ptrex, it will be very useful to me.

@ofLight: do you mean this works without office installed? just with modi2003.exe installed? i'll try removing office to verify this.

btw if anyone has trouble getting modi2003.exe i can upload it somewhere, unless i'm not allowed to (haven't actually READ the eula, lol)

#79 BotWriter

BotWriter

    Seeker

  • New Members
  • 2 posts

Posted 01 November 2008 - 09:05 PM

oh hi. great work on this, ptrex, it will be very useful to me.

@ofLight: do you mean this works without office installed? just with modi2003.exe installed? i'll try removing office to verify this.

btw if anyone has trouble getting modi2003.exe i can upload it somewhere, unless i'm not allowed to (haven't actually READ the eula, lol)


It is available to download from Microsoft at modi2003.exe download.

BotWriter

#80 S0789300

S0789300

    Seeker

  • Active Members
  • 32 posts

Posted 08 January 2009 - 03:10 PM

I hope Ptrex et al. are still willing to answer questions regarding this script... I see that a lot of people are having success with it which makes me feel great! I however, am getting COM errors and believe I have checked everything that others have said.

I have created a .tiff and placed it in C:\Temp\MyPic.tiff
I have objects in the C:\Program Files\Common Files\Microsoft Shared\MODI\12.0\ -- specifically 30 files, including dll's for a total of 6.7 MB, no M*.dll though

I am getting a rough total of 9 COM errors, and an error when closing the MODI window. I have taken a screenshot of the sorts of COM errors I am getting and hope someone can point in my in the right direction. I have office 2007, and have also tried downloading the '03 MODI executable. It dumps 2 files, one HTML file and one CHM file so I am unsure if that is the way to go - regardless I do have the 2007 MODI objects as stated above.

Could anyone lend assistence? I would love to be able to use Ptrex source and maybe even the minicap dumps provided by trids. You guys are great, any help would be greatly appreciated. Cheers.

PS: I could be missing something totally stupid-simple, so please dont hold it against me :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users