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 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