|This object 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 object is used to perform optical character recognition in the visible area of an onscreen object. To get the
OCRObject object, call the
OCR.CreateObject method and pass it the needed on-screen object as a parameter.
The following example captures an image of the Windows Notepad window and uses it to create a new
OCRObject. After that, it recognizes the characters written in Notepad and posts them to the test log.
def OCRobjectSample(): # Obtains the Notepad window notepad = Sys.Process("notepad") Window = notepad.Window("Notepad", "*").Window("Edit") # Captures an image of the Notepad window and posts it to the test log Rect = Window.Picture() Log.Picture(Rect, "Region with the text to be recognized") # Creates an OCR object OCRObj = OCR.CreateObject(Rect) # Recognizes the text and posts it to the test log Log.Message("Recognized text:", OCRObj.GetText())