Sign in to follow this  
Followers 0
MrHeadScratcher

Free OCR and AutoIT

8 posts in this topic

Hi,

I started yesterday using AutoIT. I want to automate document scanning using FreeOCR. At the moment I am stuck because I am not able to access my toolbar.

Here is my code:

Run("C:\Program Files\FreeOCR\FreeOCR.exe")
WinActivate("FreeOCR V3 Free OCR Software")
$var = ControlClick("[CLASS:WindowsForms10.window.8.app.0.33c0d9d]", "ToolStrip1", "198670")
MsgBox($var)

I tried all possible variations of ControlClick parameters and I always get the message "==> Incorrect number of parameters in function call.:". What am I doing wrong? I don't want to use MouseClick.

best, MHS

Share this post


Link to post
Share on other sites



I think you are missing out the text parameter: ControlClick("Title", "Text", "Control", "primary", 1, $x, $y)

Have you tried using GUIToolbar UDF?? Use #include<GUIToolbar.au3>, and then you want functions like _GUICtrlToolbar_ClickIndex. It should be more reliable than relying on x and y coords.

Something like:

#include<GUIToolbar.au3>

$i = 0 ; Index to click
$hToolbar = ControlGetHandle("Window Title", "", "Toolbar1")
_GUICtrlToolbar_ClickIndex($hToolbar, $i)

Mat

Share this post


Link to post
Share on other sites

Hi,

I tried your suggestion but I am stuck now because I don't know the index paramter:

#Include <GuiToolBar.au3>
_GUICtrlToolbar_ClickIndex($hWnd, $iIndex[, $sButton = "left"[, $fMove = False[, $iClicks = 1[, $iSpeed = 1]]]])

I also can't use ClickButton because of the command id:

#Include <GuiToolBar.au3>
_GUICtrlToolbar_ClickButton($hWnd, $iCommandID[, $sButton = "left"[, $fMove = False[, $iClicks = 1[, $iSpeed = 1]]]])

Is there a function to get this info?

best, MHS

Share this post


Link to post
Share on other sites

The index is simple, you count what number the item is. For the Command Id, there is a 'Toolbar' tab in the window info tool that ships with AutoIt. It lists all the toolbar items Id and Text.

Share this post


Link to post
Share on other sites

Hi,

I have no entries in Toolbar tab only empty columns "Index", "Command ID" and "Text".

best, MHS

Share this post


Link to post
Share on other sites

This toolbar is not "Windows Standard" so you'll have to use coordinates. The good news is that this toolbar cannot be resized so your coordinates should be the same (or at least similar if you click on the middle of the button with the AU3 Window INfo Tool) desktop resolution.

Share this post


Link to post
Share on other sites

Hi,

Ok. I use now Mouseclick. If I maximize the window before all button-positions will be the same. Thanks for the help.

best, MDS

Share this post


Link to post
Share on other sites

You do not have to maximize the Window if you don't want to. My toolbar is always 65 pixels high, maximized or not. The x coordinate of the buttons does not change either. So if you just specify the X coordinate of the button you want to click, it should work. This works for me on the Open PDF button

Opt('WinTitleMatchMode', 4)
ControlClick("[CLASS:WindowsForms10.window.8.app.0.378734a]", "", "ToolStrip1", "left", 1, 174)

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
Sign in to follow this  
Followers 0