|This method is provided by the legacy OCR plugin. In version 12.60, the plugin was replaced with the new Optical Character Recognition plugin powered by Google Cloud Vision API. To learn more, see Optical Character Recognition.
The legacy OCR plugin was removed from TestComplete in version 12.60. If you need to use objects, methods, and properties provided by the legacy plugin with this version of TestComplete, please contact our Customer Care team. The legacy OCR plugin was restored in TestComplete version 14.0. To use the objects, methods, and properties with this or later TestComplete version, you need to install and enable the plugin manually.
OCRObject.FindRectByText method lets you recognize all of the text within the visible area of an onscreen object and searches for a rectangular region in this area by the text this region holds.
|OCRObjectObj||An expression, variable or parameter that specifies a reference to an OCRObject object|
The method is applied to the following object:
The method has the following parameters:
Specifies the sought-for text.
OCROptions object that includes settings to be used during character recognition.
True if a region that holds the sought-for text is found and False otherwise.
If the method finds the region that includes the sought-for text, the
FoundY properties of the
OCRObject object will have the values that correspond to the found region.
The method can search for the exact match of the given string or for a string that is similar to the given string. This behavior is controlled by the
OCROptions.ExactSearch setting. The amount of string similarity is set by the
A number of factors affect the recognition accuracy, read the Using Optical Character Recognition - Tips topic to learn how to improve it.
The following example searches for the string “Test” in the Notepad window and posts an image of the found rectangular region to the test log.
def Test(): # Obtain the Notepad window notepad = Sys.Process("notepad") Window = notepad.Window("Notepad", "*").Window("Edit") # Capture an image of the Notepad window and post it to the test log Rect = Window.Picture() Log.Picture(Rect, "Region with the text to be recognized") # Create an OCR object OCRObj = OCR.CreateObject(Rect) if OCRObj.FindRectByText("Test"): Log.Picture(Window.Picture(OCRObj.FoundLeft, OCRObj.FoundTop, OCRObj.FoundWidth, OCRObj.FoundHeight), "Found region.")