Colors Property

Applies to TestComplete 15.45, last modified on December 01, 2022
This property 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.

Description

The FontCollection.Colors property lets you get an IntCollection object that represents a collection of colors to be used during character recognition. Individual colors in this collection must be specified by the corresponding integer values. For instance, you can use the color constants defined in the BuiltIn object, which are available in the Code Completion window. These constants have the cl prefix (e.g. clAqua). For a list of predefined color constants and instructions on how to calculate custom color values, see the Working With Colors topic.

Declaration

FontCollectionObj.Colors

Read-Only Property An IntCollection object
FontCollectionObj An expression, variable or parameter that specifies a reference to a FontCollection object

Applies To

The property is applied to the following object:

Property Value

An IntCollection object that represents the color collection.

Example

The code below creates a font collection for recognition of the specified object and then gets the text of this object.

JavaScript, JScript

function ColorsExample()
{
  // Specifies the object to get access to
  var Obj = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1);
  // Creates an OCR object
  var OCRObj = OCR.CreateObject(Obj);
  // Creates a color collection for the specified object
  var ColorsOptions = OCRObj.CreateOptions;
  var ColorsCol = ColorsOptions.Fonts.Colors;
  ColorsCol.Add(0xFFFF00); // Aqua
  ColorsCol.Add(0xFF00FF); // Fuchsia (Magenta)
  // ...
  
  // Gets the text of the specified object using the defined OCR options
  OCRObj.GetText(ColorsOptions);
  
}

Python

def ColorsExample():
  # Specifies the object to get access to
  Obj = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1)
  # Creates an OCR object
  OCRObj = OCR.CreateObject(Obj)
  # Creates a color collection for the specified object
  ColorsOptions = OCRObj.CreateOptions()
  ColorsCol = ColorsOptions.Fonts.Colors
  ColorsCol.Add(0xFFFF00) # Aqua
  ColorsCol.Add(0xFF00FF) # Fuchsia (Magenta)
  # ...
  # Gets the text of the specified object using the defined OCR options
  OCRObj.GetText(ColorsOptions)

VBScript

Sub ColorsExample

  ' Specifies the object to get access to
  Set Obj = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1)
  ' Creates an OCR object
  Set OCRObj = OCR.CreateObject(Obj)
  ' Creates a color collection for the specified object
  Set ColorsOptions = OCRObj.CreateOptions
  Set ColorsCol = ColorsOptions.Fonts.Colors
  ColorsCol.Add(&hFFFF00) ' Aqua
  ColorsCol.Add(&hFF00FF) ' Fuchsia (Magenta)
  ' ...
  
  ' Gets the text of the specified object using the defined OCR options
  OCRObj.GetText(ColorsOptions)
  
End Sub

DelphiScript

function ColorsExample;
var Obj, OCRObj, ColorsCol;
begin

  // Specifies the object to get access to
  Obj := Sys.Process('notepad').Window('Notepad', 'Untitled - Notepad', 1);
  // Creates an OCR object
  OCRObj := OCR.CreateObject(Obj);
  // Creates a color collection for the specified object
  ColorsOptions := OCRObj.CreateOptions();
  ColorsCol := ColorsOptions.Fonts.Colors;
  ColorsCol.Add($FFFF00); // Aqua
  ColorsCol.Add($FF00FF); // Fuchsia (Magenta)
  // ...
  
  // Gets the text of the specified object using the defined OCR options
  OCRObj.GetText(ColorsOptions);
  
end;

C++Script, C#Script

function ColorsExample()
{
  // Specifies the object to get access to
  var Obj = Sys["Process"]("notepad")["Window"]("Notepad", "Untitled - Notepad", 1);
  // Creates an OCR object
  var OCRObj = OCR["CreateObject"](Obj);
  // Creates a color collection for the specified object
  var ColorsOptions = OCRObj["CreateOptions"];
  var ColorsCol = ColorsOptions["Fonts"]["Colors"];
  ColorsCol["Add"](0xFFFF00); // Aqua
  ColorsCol["Add"](0xFF00FF); // Fuchsia (Magenta)
  // ...
  
  // Gets the text of the specified object using the defined OCR options
  OCRObj["GetText"](ColorsOptions);
  
}

See Also

IntCollection Object
Using Optical Character Recognition
Working With Colors

Highlight search results