Jump to content

Help with coding FreeOCR


Recommended Posts

Hello people,

I have a problem with making the FreeOCR wizard unattended. so that's why i am asking for you help.

this is the code i am using (theoretically it should work but it doesn't).

Run("freeocr541.exe") 
WinWaitActive("Setup - FreeOCR") 
Send("!N") 
Send("!a")
Send("!N")
Send("!N")
Send("!I")

 

Hoping anyone can help me.

-Smolenaars

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum. Please pay attention to where you post in the future

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Developers

You aren't telling us yet what is going wrong, but likely you send the keystrokes too fast.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

A super easy way would be to use the ControlClick feature. All you have to do is get the control ID of the button. Use the AutoIt Window Info tool found in the autoit folder in your start menu.

ControlClick ( "title", "text", controlID [, button = "left" [, clicks = 1 [, x [, y]]]] )

 

https://www.autoitscript.com/autoit3/docs/functions/ControlClick.htm

Link to comment
Share on other sites

Thanks for the help but that didn't quite fix my problem.

the new problem is that it gives an error when i try to run it.

it also starts up the Setup twice.

 the script i am using is the following:

Run("freeocr541.exe")

Local $iPID = WinWait("[CLASS:TWizardForm]", "", 10)

ControlClick ($iPID "Setup - FreeOCR", "Welcome to the FreeOCR Setup Wizard", controlID [, button = "left" [, clicks = 1[, 260 [, 170]]]])

 

It gives the following error:

ControlClick ($iPID "Setup - FreeOCR", "Welcome to the FreeOCR Setup Wizard", controlID [, button = "left" [, clicks = 1[, 260 [, 170]]]]) ControlClick (^ERROR

Error: Error in expression.

Link to comment
Share on other sites

  • Developers

Those [] shouldn't be in there and are just an indicator in the helpfile that these parameters are optional.
Have you tried building a sleep() between the send() commands to ensure you aren't sending them too fast?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I am using this script, it works with other setups but it doesn't work with the FreeOCR setup.

Run("freeocr541.exe")
WinWait("Setup - FreeOCR")
controlSend("Setup - FreeOCR", "", "[CLASS:TNewButton; INSTANCE:1]", "&Next >")

 

I also tried it with the controlclick but that didn't work just like this one doesn't.

Link to comment
Share on other sites

  • Moderators

freeocr is very resistant to ControlClicks; I have run into it myself when packaging this application. Even though the controls show up on the Window Info Tool, you cannot interact with them. My suggestion would be either A: look at the IUIAutomation thread in the Examples forum, or B (more reliable): use Wix or some other open source tool to create an MSI from the installer, which you then can install silently.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Here you go buddy. Works on win7

Edit: The ID changes when the application is opened.. does someone know why the ID changes?

#RequireAdmin ; must include when installing

Example()

Func Example()

    Local $hWnd = WinWait("[CLASS:TWizardForm]", "", 10) ; use AutoIt v3 Window Info tool
    ; located in the AutoIt folder.

    WinActivate($hWnd) ; WinActivate sets Setup - FreeOCR as an active screen

    ;Notes:
    ;ControlClick("title", "text", controlID[, button = "left"[, clicks = 1[, x[, y]]]])
            ;  title =>> $hWnd = WinWait("[CLASS:TWizardForm]
            ; "text" =>> "&Next >"
            ; controlID =>> 329210

    ControlClick($hWnd, "&Next >", 329210) ;

EndFunc   ;==>Example

 

Process.png

Edited by aa2zz6
One last final thought :|
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...