TextUtil Object

Description

The object used to recognize text within a specified window handle.

IMPORTANT

When possible, it is recommended to use alternative methods of capturing text instead of using the TextUtil object. For example:

  • Use the GetROProperty method or the Object property to retrieve the value of the text (or equivalent) property from an object in your application

  • Use a text or text area output value step to retrieve text or a text or text area checkpoint step to verify a text value.

  • Use the GetVisibleText or GetTextLocation methods of the appropriate test object.

For more details on text and text area checkpoints, see the Micro Focus UFT One User Guide. For more details on the GetVisibleText method, see the relevant section in the Micro Focus UFT One Object Model Reference for GUI Testing.

Methods

Method ClearOCRCacheClears OCR result cache.
Method GetTextReturns the text from the specified window handle area.
Method GetTextFromImage

Returns the text from a specified area in an image file.

Method GetTextLocationChecks whether the text string is contained in the window area and returns the string's location.
Method GetTextLocationFromImage

Checks whether the text string is contained in the image file and returns the string's location.

Method ResetABBYYParametersResets ABBYY OCR recognition parameters.
Method SetABBYYParametersSets ABBYY OCR recognition parameters for the current test run.

Back to top

ClearOCRCache Method

Description

Clears the OCR result cache, which stores any texts retrieved from images in the current run to improve OCR performance.

Use this method if you change the OCR settings (for example, using SetABBYYParameters) during a test run and want these changes to affect an image whose text was previously retrieved in this test run.

Syntax

TextUtil.ClearOCRCache()

Return Value

None

IMPORTANT

This method clears the cached information for all images. Any text retrieved earlier in the test run needs to be retrieved again, which may affect your test's performance.

Back to top

GetText Method

Description

Returns the text from the specified window handle area. The area is defined by pairs of coordinates that designate two diagonally opposite corners of a rectangle.

Syntax

TextUtil.GetText(hWnd, [Left, Top, Right, Bottom])

Argument

Type

Description

hWnd

Number

The handle to a run-time object's window.

Note:  

  • If hWnd is not 0, then the coordinate arguments apply to the specified window. If hWnd is 0, the coordinates apply to the screen.

  • The value 0 is not supported when running steps on Vista operating systems or higher, or on any 64-bit operating system.

Left, Top, Right, Bottom

Number

Optional. These arguments define the search area within the window or screen.

Note: If these arguments are not specified, the method returns all text contained in the window or screen.

Return Value

String

IMPORTANT

  • The text to capture must be visible in the application window when the step runs.

  • When possible, it is recommended to use alternative methods of capturing text. For more details, see the IMPORTANT section above.

  • The results of this method may be different depending on the settings selected in the Text Recognition pane of the Options dialog box (Tools > Options > GUI Testing tab > Text Recognition node).

  • The results of this method may be different in different run sessions depending on the operating system version you are using, service packs you have installed, other installed toolkits, the APIs used in your application, and so on. Therefore, when possible, it is highly recommended to use alternative ways retrieve the value of the text (or equivalent) property from an object in your application instead of using the GetText method, as described in the Important Information section of the TextUtil Object.

Back to top

GetTextFromImage Method

Description

Returns the text from a specified area in an image file.

Syntax

TextUtil.GetTextFromImage(FilePath, [Left, Top, Right, Bottom])

Argument

Type

Description

FilePath

String

The path to the image file. Supported image file types: BMP, GIF, JPEG, PNG, and TIFF.

Left, Top, Right, Bottom

Number

Optional. These arguments define the search area within the image.

Note: If these arguments are not specified, the method returns all text contained in the image.

Return Value

String

IMPORTANT

  • When possible, it is recommended to use alternative methods of capturing text. For more details, see the IMPORTANT section above.

  • The results of this method may be different depending on the settings selected in the Text Recognition pane of the Options dialog box (Tools > Options > GUI Testing tab > Text Recognition node).

  • The results of this method may be different in different run sessions depending on the operating system version you are using, service packs you have installed, other installed toolkits, the APIs used in your application, and so on. Therefore, when possible, it is highly recommended to use alternative ways retrieve the value of the text (or equivalent) property from an object in your application instead of using the GetTextFromImage method, as described in the Important Information section of the TextUtil Object.

Back to top

GetTextLocation Method

Description

Checks whether a specified text string is contained in a specified window area. If the text string is located, the location coordinates are also returned.

Syntax

TextUtil.GetTextLocation(TextToFind, hWnd, Left, Top, Right, Bottom)

Argument

Type

Description

TextToFind

String

The text string you want to locate.

hWnd

Number

The handle to a run-time object's window.

    Note:
  • If hWnd is not 0, then the coordinate arguments apply to the specified window. If hWnd is 0, the coordinates apply to the screen.

  • The value 0 is not supported when running steps on Vista operating systems or higher, or on any 64-bit operating system.

Left, Top, Right, Bottom

InOut, Number

These arguments define the search area within the window or screen.

Set all coordinates to -1 (or leave their values unset) to search for the text string within the entire window or screen.

The method returns the coordinates of the rectangle containing the first instance of the text into these variables if the text is found.

Return Value

Boolean

IMPORTANT

  • The text to capture must be visible in the application window when the step runs.

  • This method returns True only if the TextToFind argument value is found within a single line in the specified area. The text search restarts on each line of text.

  • If the TextToFind argument value includes a space, then this method searches for that text as whole words. For example, if you search for "a b" and the text "bla bla" exists, the method will still return False.

  • If the text is found (return value = True) and if the Left, Top, Right, and Bottom arguments are supplied as variables, then the method also returns the exact coordinates of the specified text to the supplied arguments (the returned coordinates overwrite the supplied ones).

  • The results of this method may be different depending on the settings selected in the Text Recognition pane of the Options dialog box (Tools Options > GUI Testing tab > Text Recognition node).

  • The results of this method may be different in different run sessions depending on the operating system version you are using, service packs you have installed, other installed toolkits, the APIs used in your application, and so on. Therefore, when possible, it is highly recommended to use alternative ways retrieve the value of the text (or equivalent) property from an object in your application instead of using the GetText method, as described in the Important Information section of the TextUtil Object.

Back to top

GetTextLocationFromImage Method

Description

Checks whether a specified text string is contained in a specified image file. If the text string is located, the location coordinates are also returned.

Syntax

TextUtil.GetTextLocationFromImage(TextToFind, FilePath, Left, Top, Right, Bottom[, MatchWholeWordOnly])

Argument

Type

Description

TextToFind

String

The text string you want to locate.

FilePath

String

The path to the image file. Supported image file types: BMP, GIF, JPEG, PNG, and TIFF.

Left, Top, Right, Bottom

InOut, Number

These arguments define the search area within the image.

Set all coordinates to -1 (or leave their values unset) to search for the text string within the entire window or screen.

The method returns the coordinates of the rectangle containing the first instance of the text into these variables if the text is found.

Return Value

Boolean

IMPORTANT

  • This method returns True only if the TextToFind argument value is found within a single line in the specified area. The text search restarts on each line of text.

  • If the TextToFind argument value includes a space, then this method searches for that text as whole words. For example, if you search for "a b" and the text "bla bla" exists, the method will still return False.

  • If the text is found (return value = True) and if the Left, Top, Right, and Bottom arguments are supplied as variables, then the method also returns the exact coordinates of the specified text to the supplied arguments (the returned coordinates overwrite the supplied ones).

  • The results of this method may be different depending on the settings selected in the Text Recognition pane of the Options dialog box (Tools Options > GUI Testing tab > Text Recognition node).

  • The results of this method may be different in different run sessions depending on the operating system version you are using, service packs you have installed, other installed toolkits, the APIs used in your application, and so on. Therefore, when possible, it is highly recommended to use alternative ways retrieve the value of the text (or equivalent) property from an object in your application instead of using the GetText method, as described in the Important Information section of the TextUtil Object.

Back to top

ResetABBYYParameters Method

Description

Resets ABBYY OCR recognition parameters.

Syntax

TextUtil.ResetABBYYParameters()

Return Value

None

IMPORTANT

You can use this method to return to the global ABBYY OCR settings after using custom ABBYY settings (SetABBYYParameters) for part of the test run.

Back to top

SetABBYYParameters Method

Description

Sets ABBYY OCR recognition parameters for the current test run.

Syntax

TextUtil.SetABBYYParameters(ParamName, Enable, [EnumIndex])

Argument

Type

Description

ParamName

String

The text recognition parameter you want to set for ABBYY OCR engine.

Possible Values:

  • detectTextOnPictures

    Instructs the ABBYY OCR engine to detect all text on a page image, including text embedded into figures and pictures.

  • enableAggressiveTextExtraction

    Instructs the ABBYY OCR engine to extract as much text on the image as possible.

  • enableTextExtractionMode

    Instructs the ABBYY OCR engine to extract text from text blocks.

  • oneWordPerLine

    Instructs the ABBYY OCR engine to recognize the lines of text as a single word.

  • fastObjectsExtraction

    Instructs the ABBYY OCR engine to speed up objects extraction.

  • removeGarbage

    Instructs the ABBYY OCR engine to remove garbage from the image during objects extraction.

  • removeTexture

    Instructs the ABBYY OCR engine to remove the background noise from a temporary image used for recognition.

  • useFastBinarization

    Instructs the ABBYY OCR engine to use fast image binarization.

  • correctSkew

    Instructs the ABBYY OCR engine to correct skew during image preparation.

  • prohibitColorImage

    Instructs the ABBYY OCR engine to use only black-and-white plane during objects extraction.

  • discardColorImage

    Instructs the ABBYY OCR engine to leave only black-and-white plane in the prepared image.

  • fastMode

    Instructs the ABBYY OCR engine to provide faster recognition speed.

  • lowResolutionMode

    Instructs the ABBYY OCR engine to recognize a text on an image with low resolution.

  • prohibitItalic

    Instructs the ABBYY OCR engine to not recognize letters printed with italic-styled font.

  • prohibitSubscript

    Instructs the ABBYY OCR engine to not recognize subscript letters.

  • prohibitSuperscript

    Instructs the ABBYY OCR engine to not recognize superscript letters.

  • prohibitHyphenation

    Instructs the ABBYY OCR engine to prohibit recognition of hyphenation from line to line.

  • caseRecognitionMode

    Specifies the mode of letter case recognition.

  • fieldMarkingType

    Specifies the type of marking around letters (for example, underline, frame, box, etc.).

Enable

Boolean

Indicates whether to enable the ABBYY parameter.

Possible values:

  • True

  • False

EnumIndex

Integer

Optional. The index number of the value of the ABBYY parameter in an enumeration.

This argument is mandatory when you set bsParameter to caseRecognitionMode or fieldMarkingType.

Possible values when you set bsParameter to caseRecognitionMode:

  • 0: Auto Case

  • 1: Lower Case

  • 2: Upper Case

Possible values when you set bsParameter to fieldMarkingType:

  • 0: Simple Text

  • 1: Underlined Text

  • 2: Text In Frame

  • 3: Gray Boxes

  • 4: Char Box Series

  • 5: Simple Comb

  • 6: Comb In Frame

  • 7: Partitioned Frame

Return Value

None

IMPORTANT

After using custom ABBYY settings for part of the test run, you can use ResetABBYYPrameters to return to the global ABBYY OCR settings.

See also: