FoundX Property

Applies to TestComplete 12.60, last modified on September 17, 2018
The Optical Character Recognition feature provided by the OCR plugin is deprecated. It was removed from TestComplete in version 12.60 and is no longer available for later versions.
Instead, TestComplete version 12.60 introduces the new Optical Character Recognition engine featuring Google Cloud Vision API. To learn more, see Optical Character Recognition.
If you need to use the legacy feature, please contact our Customer Care team.

Description

The OCRObject.FoundX property returns the horizontal coordinate of the center of the rectangular region found in an onscreen object with OCRObject.FindRectByText.

Declaration

OCRObjectObj.FoundX

Read-Only Property Integer
OCRObjectObj An expression, variable or parameter that specifies a reference to an OCRObject object

Applies To

The property is applied to the following object:

Property Value

An integer value that denotes the horizontal coordinate of the center of the found rectangular region.

Example

The following example obtains the text entered in the Notepad window and simulates a mouse click in the center of the rectangular area that contains the found text.

JavaScript, JScript

function OCROptionsSample()
{
  var notepad, Window, Rect, OCRObj, s, X, Y;
  // 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);

  // Recognize the text
  s = OCRObj.GetText();

  // Post the recorgnized text to the test log
  Log.Message("See the recognized text in the Additional Info panel.", s);

  if (s != "")
  {
    // Obtain the coordinates of the found region’s center
    X = OCRObj.FoundX;
    Y = OCRObj.FoundY;
    // Click the center of the region that contains the found text
    Window.Click(X, Y);
  }

}

Python

def OCROptionsSample():
  # 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)
  # Recognize the text  
  s = OCRObj.GetText()
  # Post the recorgnized text to the test log 
  Log.Message("See the recognized text in the Additional Info panel.", s)
  if s != "":
    # Obtain the coordinates of the found region’s center  
    X = OCRObj.FoundX
    Y = OCRObj.FoundY
    # Click the center of the region that contains the found text 
    Window.Click(X, Y)

VBScript

Sub OCROptionsSample

  ' Obtain the Notepad window
  Set notepad = Sys.Process("notepad")
  Set Window = notepad.Window("Notepad", "*").Window("Edit")

  ' Capture an image of the Notepad window and post it to the test log
  Set Rect = Window.Picture
  Call Log.Picture(Rect, "Region with the text to be recognized")

  ' Create an OCR object
  Set OCRObj = OCR.CreateObject(Rect)

  ' Recognize the text
  s = OCRObj.GetText()

  ' Post the recorgnized text to the test log
  Call Log.Message("See the recognized text in the Additional Info panel.", s)

  If not s = "" Then
    ' Obtain the coordinates of the found region’s center
    X = OCRObj.FoundX
    Y = OCRObj.FoundY
    ' Click the center of the region that contains the found text
    Call Window.Click(X, Y)
  End If

End Sub

DelphiScript

procedure OCROptionsSample();
var notepad, Window, Rect, OCRObj, s, X, Y: OleVariant;
begin
  // 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);

  // Recognize the text
  s := OCRObj.GetText();

  // Post the recorgnized text to the test log
  Log.Message('See the recognized text in the Additional Info panel.', s);

  if (s <> '') then
  begin
    // Obtain the coordinates of the found region’s center
    X := OCRObj.FoundX;
    Y := OCRObj.FoundY;
    // Click the center of the region that contains the found text
    Window.Click(X, Y);
  end;

end;

C++Script, C#Script

function OCROptionsSample()
{
  var notepad, Window, Rect, OCRObj, s, X, Y;
  // 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);

  // Recognize the text
  s = OCRObj["GetText"]();

  // Post the recorgnized text to the test log
  Log["Message"]("See the recognized text in the Additional Info panel.", s);

  if (s != "")
  {
    // Obtain the coordinates of the found region’s center
    X = OCRObj["FoundX"];
    Y = OCRObj["FoundY"];
    // Click the center of the region that contains the found text
    Window["Click"](X, Y);
  }
}

See Also

OCRObject.FoundY
OCRObject.FoundHeight
OCRObject.FoundWidth
OCRObject.FoundTop
OCRObject.FoundLeft
OCRObject.FindRectByText
Using Optical Character Recognition - Tips

Highlight search results