CitrixParseText Function

Action

This function performs optical character recognition (OCR) on a selected screen region and stores the result in a sResult parameter. Screen regions can be specified absolutely or relative to a window (by specifying a window handle).

注: OCR operations are only possible in Normal Mode (see CitrixInit). This function fails when used in Fast Mode. When the optional font parameters are present, the pattern file is checked for the used font’s availability. When the parameters are omitted font checking is not performed.

For successful text conversion it is necessary to use the perfOcrFonts.dat and perfOcrPattern.pat configuration files, which contain the used fonts in the correct size and format. These two files must be added to the Data Files section of the project (both files are located at <public user documents>\Silk Performer 20.5\Data). If the files do not exist, or they do not contain the right specifications, they can be generated or updated using the OCR dialog in the Citrix System Settings.

Include file

CitrixAPI.bdh

Syntax

CitrixParseText( out sResult    : string,
                 in  nWindow    : number,
                 in  nX         : number,
                 in  nY         : number,
                 in  nWidth     : number,
                 in  nHeight    : number,
                 in  sFont      : string optional,
                 in  nFontSize  : number optional,
                 in  nFontFlags : number optional ) : boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
sResult String variable that receives the converted text.
nWindow Window handle returned by a call to CitrixWaitForWindowCreation. Use DESKTOP to specify a region relative to the desktop.
nX X coordinate of the left margin of the screen region.
nY Y coordinate of the top margin of the screen region.
nWidth Width of the region.
nHeight Height of the region
sFont Font that should be checked for on the system and in the provided configuration files (optional). This parameter does not affect the conversion; it enables rapid fault detection when using remote agents and moving projects to different hosts. When a specified font is not on the operating system, it must be installed. If the provided configuration files do not contain the font, use the OCR configuration dialog (System Settings / Citrix) to adjust them. When this parameter is omitted font checking is not performed.
nFontSize The font size that should be checked for in the provided configuration files (optional). This parameter does not affect the conversion; it enables rapid fault detection when using remote agents and moving projects to different hosts. If the provided configuration files do not contain the font-size, use the OCR configuration dialog (System Settings / Citrix) to adjust them. When this parameter is omitted font-size checking is not performed.
nFontFlags

Specifies the font shape (bold, italic, or underlined) that should be checked for in the provided configuration files (optional). This parameter does not affect the conversion; it enables rapid fault detection when using remote agents and moving projects to different hosts. If the provided configuration files do not contain the specified font shapes, use the OCR configuration dialog (System Settings / Citrix) to adjust them. When this parameter is omitted font-shape checking is not performed.

Specify any combination of the following values:

  • FONT_FLAG_Italic

  • FONT_FLAG_Bold

  • FONT_FLAG_Underlined

Example

  transaction TMain
  var
    sParam1 : string;
  begin
    CitrixInit(640, 480); // do not change the resolution
    CitrixConnect("lab1", "user", "password", "domain", COLOR_16bit);
    CitrixWaitForLogon();
    CitrixParseText(sParam1, DESKTOP, 73, 109, 74, 23, "Tahoma", 8); 
    Print("sParam1: " + sParam1);
    CitrixDisconnect();
  end TMain;