Smolenaars

Help with coding FreeOCR

16 posts in this topic

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

Share this post


Link to post
Share on other sites



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


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

ow sorry, it starts without a problem but then doesnt go to the next wizard page.

 

i tested a sleep 10000 but that didnt change anything.

any ideas of how i could solve it.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I installed it on my vm win10. I'll take a look at it in a minute

 

Edit: Are you using the send command to install it? If so I think there's a better way.

Edited by aa2zz6

Share this post


Link to post
Share on other sites

i am using the send command to click on the next button yes.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Removed the [] and inplemented the Sleep(), my problem is still the same though.

It still gives the same Error: Error in expression.

Any other ideas what might cause this?

Share this post


Link to post
Share on other sites

Smolenaars,

Post the script that issues the error and the run log.

Are you using the full version of SCITE?

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Or...
 You could use a silent switch. Example:

Run(@ScriptDir & "\freeocr541.exe /silent")

The above shows the install progress screens. To make it completely silent, use "/verysilent" instead of "/silent".


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
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