Jump to content

_TesseractScreenFind()


Recommended Posts

When I use _TesseractScreenFind(), from Tesseract.au3. It returns a number, but it doesn't return an array. Does it return the coordinates of where it finds the text? I'm trying to move the mouse to where the text is found, but I don't see how that's possible if only one number is returned. I need two numbers for the x and y coordinates.

Edited by Phenom
Link to comment
Share on other sites

Open the UDF file and look at the function's header for what the return values are (this is a general troubleshooting step you should use a lot):

; #FUNCTION# ;===============================================================================
;
; Name...........:  _TesseractScreenFind()
; Description ...:  Finds the location of a string within text captured from the screen.
; Syntax.........:  _TesseractScreenFind($find_str = "", $partial = 1, $get_last_capture = 0, $delimiter = "", $cleanup = 1, $scale = 2, $left_indent = 0, $top_indent = 0, $right_indent = 0, $bottom_indent = 0, $show_capture = 0)
; Parameters ....:  $find_str           - The text (string) to find.
;                   $partial            - Optional: Find the text using a partial match?
;                                           0 = use a full text match
;                                           1 = use a partial text match (default)
;                   $get_last_capture   - Search within the text of the last capture, rather than
;                                           performing another capture.  Useful if the text in
;                                           the window or control hasn't changed since the last capture.
;                                           0 = do not use the last capture (default)
;                                           1 = use the last capture
;                   $delimiter          - Optional: The string that delimits elements in the text.
;                                           A string of text will be searched if this isn't provided.
;                                           The index of the item found will be returned if this is provided.
;                                           Eg. Use @CRLF to find an item in a listbox.
;                   $cleanup            - Optional: Remove invalid text recognised
;                                           0 = do not remove invalid text
;                                           1 = remove invalid text (default)
;                   $scale              - Optional: The scaling factor of the screenshot prior to text recognition.
;                                           Increase this number to improve accuracy.
;                                           The default is 2.
;                   $left_indent        - A number of pixels to indent the capture from the
;                                           left of the screen.
;                   $top_indent         - A number of pixels to indent the capture from the
;                                           top of the screen.
;                   $right_indent       - A number of pixels to indent the capture from the
;                                           right of the screen.
;                   $bottom_indent      - A number of pixels to indent the capture from the
;                                           bottom of the screen.
;                   $show_capture       - Display screenshot and text captures
;                                           (for debugging purposes).
;                                           0 = do not display the screenshot taken (default)
;                                           1 = display the screenshot taken and exit
; Return values .:  On Success          - Returns the location of the text that was found.
;                                           If $delimiter is "", then the character position of the text found
;                                               is returned.
;                                           If $delimiter is not "", then the element of the array where the
;                                               text was found is returned.
;                   On Failure          - Returns an empty array.
; Author ........:  seangriffin
; Modified.......: 
; Remarks .......:  
; Related .......: 
; Link ..........: 
; Example .......:  No
;
; ;==========================================================================================
func _TesseractScreenFind($find_str = "", $partial = 1, $get_last_capture = 0, $delimiter = "", $cleanup = 1, $scale = 2, $left_indent = 0, $top_indent = 0, $right_indent = 0, $bottom_indent = 0, $show_capture = 0)

     ; ...

EndFunc   ;==>_TesseractScreenFind

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The Tesseract UDF is not part of the regular AutoIt distro. You have to download it separately from the forum. (See the forum search.)

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Open the UDF file and look at the function's header for what the return values are (this is a general troubleshooting step you should use a lot):

; #FUNCTION# ;===============================================================================
;
; Name...........:  _TesseractScreenFind()
; Description ...:  Finds the location of a string within text captured from the screen.
; Syntax.........:  _TesseractScreenFind($find_str = "", $partial = 1, $get_last_capture = 0, $delimiter = "", $cleanup = 1, $scale = 2, $left_indent = 0, $top_indent = 0, $right_indent = 0, $bottom_indent = 0, $show_capture = 0)
; Parameters ....:  $find_str           - The text (string) to find.
;                   $partial            - Optional: Find the text using a partial match?
;                                           0 = use a full text match
;                                           1 = use a partial text match (default)
;                   $get_last_capture   - Search within the text of the last capture, rather than
;                                           performing another capture.  Useful if the text in
;                                           the window or control hasn't changed since the last capture.
;                                           0 = do not use the last capture (default)
;                                           1 = use the last capture
;                   $delimiter          - Optional: The string that delimits elements in the text.
;                                           A string of text will be searched if this isn't provided.
;                                           The index of the item found will be returned if this is provided.
;                                           Eg. Use @CRLF to find an item in a listbox.
;                   $cleanup            - Optional: Remove invalid text recognised
;                                           0 = do not remove invalid text
;                                           1 = remove invalid text (default)
;                   $scale              - Optional: The scaling factor of the screenshot prior to text recognition.
;                                           Increase this number to improve accuracy.
;                                           The default is 2.
;                   $left_indent        - A number of pixels to indent the capture from the
;                                           left of the screen.
;                   $top_indent         - A number of pixels to indent the capture from the
;                                           top of the screen.
;                   $right_indent       - A number of pixels to indent the capture from the
;                                           right of the screen.
;                   $bottom_indent      - A number of pixels to indent the capture from the
;                                           bottom of the screen.
;                   $show_capture       - Display screenshot and text captures
;                                           (for debugging purposes).
;                                           0 = do not display the screenshot taken (default)
;                                           1 = display the screenshot taken and exit
; Return values .:  On Success          - Returns the location of the text that was found.
;                                           If $delimiter is "", then the character position of the text found
;                                               is returned.
;                                           If $delimiter is not "", then the element of the array where the
;                                               text was found is returned.
;                   On Failure          - Returns an empty array.
; Author ........:  seangriffin
; Modified.......: 
; Remarks .......:  
; Related .......: 
; Link ..........: 
; Example .......:  No
;
; ;==========================================================================================
func _TesseractScreenFind($find_str = "", $partial = 1, $get_last_capture = 0, $delimiter = "", $cleanup = 1, $scale = 2, $left_indent = 0, $top_indent = 0, $right_indent = 0, $bottom_indent = 0, $show_capture = 0)

     ; ...

EndFunc   ;==>_TesseractScreenFind

:mellow:

Yeah, I looked at that before, and couldn't figure it out. It says it returns the position, but it only returns a single number.
Link to comment
Share on other sites

Awesome, thanks a lot. After I use _TesseractControlFind() to get the character location of what I'm looking for, how can I tell me script to click at that location?

Edit: After reading through this thread again, it appears that the original poster was asking this same questions...

-hornet

Edited by hornet
Link to comment
Share on other sites

Phenom, why dont you just post the code you are using?

You say its not doing what it says it should but we only have your say so on that.

Ive tried this and it works fine.

#include <Tesseract.au3>

$pos = _TesseractScreenFind("Forums")

if IsArray($pos) Then
    MouseMove($pos[0], $pos[1])
Else
    MsgBox(0,"Error", "Coordinates not found. Value returned was " & $pos)
EndIf

It returns a number if the text is on the screen, which indicates that it found it, but what can you do with only one number?

Edited by Phenom
Link to comment
Share on other sites

If $delimiter is "", then the character position of the text found is returned.

Like PsaltyDS says, you should read the documentation, and try to understand it before using it, else you will waste your time.

Your code will return the position of the text if it is found, not the screen coordinates, which I assume you are trying to get.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I already read the documentation and I can't figure it out. I tried putting in a delimiter but it still won't return two numbers. If you read my first message, it says I'm trying to get the coordinates.

Link to comment
Share on other sites

So I think the question that Phenom and I both have is after we run this portion of the code and we have our screen shot, how can we tell our script to click at a certain point within that screen shot? When the return value only gives one number which indicates the character position, it will be hard to use mouseclick, or any other clicking command, to click at that location. To be specific, in my case anyway, I have a control that is a listbox that changes every 5 seconds or so...I need my script to search through the text within this list box and click on a certain line. The problem with this is that the specific line I need to click could be in position number 1 at one moment and then 5 seconds later could be at position number 5. Does any of that make sense? I appreciate any info regarding this.

-hornet

Link to comment
Share on other sites

Without a delimiter you get position by character count, just like you get from StringInStr().

With a delimiter you get an array index, like you might use to identify which (line) element in the array from _FileReadToArray().

In neither case do you get any screen coordinate(s).

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

$sText = "specific text"
$sText = "specific text"
$iIndex = _GUICtrlListBox_FindString($hWnd, $sText[, $fExact = False])
_GUICtrlListBox_SetCaretIndex($hWnd, $iIndex[, $fPartial = False])
_GUICtrlListBox_ClickItem($hWnd, $iIndex[, $sButton = "left"[, $fMove = False[, $iClicks = 1[, $iSpeed = 0]]]])

Edit: added SetCaretIndex to make sure found item is visable for click.

Edited by Yoriz
GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
Link to comment
Share on other sites

Ah, flash dosent have a listbox as understood by autoit, at least I dont think so anyway.

If you know the objects internal methods and properties you might be in with a chance.

Beyond that you are looking at pixel functions.

My advice: you are on a losing street but you will learn a lot on your path to despair.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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