CitrixVerifyText Function

Action

This function performs optical character recognition (OCR) on a selected screen region and compares the result with a provided string. When the verification condition is not met, an error is raised. You can specify the severity of the error. 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 will fail when used in Fast Mode.

When optional font parameters are present, the pattern file is checked to see if the selected font is available. When font 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 used fonts in the correct size and format. These 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 are not available, or do not contain the correct specifications, they can be generated or updated using the OCR dialog in the Citrix System Settings.

Include file

CitrixAPI.bdh

Syntax

CitrixVerifyText( in sVerify    : string,
                  in nWindow    : number,
                  in nX         : number,
                  in nY         : number,
                  in nWidth     : number,
                  in nHeight    : number,
                  in nOptions   : number optional,
                  in nSeverity  : number optional := SEVERITY_ERROR,
                  in sFont      : string optional,
                  in nFontSize  : number optional,
                  in nFontFlags : number optional ): boolean;

Return value

  • true if the function succeeds

  • false otherwise

Parameter Description
sVerify String to compare with the parsed data.
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
nOptions

Specify any combination of the following flags (optional):

  • CITRIX_FLAG_Equal When this flag is set the verification succeeds if the comparison succeeds (default).

  • CITRIX_FLAG_NotEqual When this flag is set the verification succeeds if the comparison fails.

  • CITRIX_FLAG_CaseSensitive When this flag is set the string compare operation is case sensitive.

  • CITRIX_FLAG_IgnoreWhitespace When this flag is set all white spaces are ignored.

nSeverity Optional: Severity of the error that is raised if the verification fails. Can be one of the following values:
  • SEVERITY_SUCCESS: Success; no error (numerical value: 0)
  • SEVERITY_INFORMATIONAL: Informational; no error (numerical value: 1)
  • SEVERITY_WARNING: Warning; no error (numerical value: 2)
  • SEVERITY_ERROR: (Default) Error; simulation continues (numerical value: 3)
  • SEVERITY_TRANS_EXIT: Error; the active transaction is aborted (numerical value: 4)
  • SEVERITY_PROCESS_EXIT: Error; the simulation is aborted (numerical value: 5)
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. If a specified font is not on the operating system, then 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
  begin
    CitrixInit(640, 480); // do not change the resolution
    CitrixConnect("lab1", "user", "password", "domain", COLOR_16bit);
    CitrixWaitForLogon();
    CitrixVerifyText("Joe", DESKTOP, 73, 109, 74, 23, CITRIX_FLAG_IgnoreWhitespace, SEVERITY_WARNING,"Tahoma", 8);
    CitrixDisconnect();
  end TMain;