ExampleCitrix Synchronization Functions

The function checks if the expected text is found in the rectangle specified by the coordinates, using optical character recognition (OCR).

Important: OCR might consume a substantial amount of the hardware resources for the load generator machine, causing high CPU consumption warnings and/or limiting the amount of Vusers that can run in parallel.

int ctrx_sync_on_text_ocr( long xpos, long ypos, long width, long height, const char *value, const char *filename, char* WaitFor, [CONTINUE_ON_ERROR,] CTRX_LAST );

xposThe horizontal distance in pixels from the left border of the ICA client window.
yposThe vertical distance in pixels from the upper border of the ICA client window.
widthOf rectangle in pixels.
heightOf rectangle in pixels.
valueThe text to for which to wait.
filenameThe snapshot file. Do not edit this value.

(Optional) The event to occur on one of the specified areas and images.

Possible values are:

  • Appear. (Default) The function waits for the specified area to match the specified text.
  • Change. The function waits for the specified area to match the specified text, and then not to match it. That is, the match is found and then the area changes so that it no longer matches.
  • NotAppear. The function returns LR_FAIL if the text appears before the function times out. If the timeout is reached and the text has not appeared, the function returns LR_PASS.
CONTINUE_ON_ERROR A constant, entered as shown without quotes. Overrides the error behavior runtime setting for this step so that script behaves as though the runtime setting was Continue on error.
CTRX_LAST A marker that indicates the end of the argument list.

ctrx_sync_on_text_ocr is a synchronization function that checks if a specified string (identified with OCR) is found in a specified rectangle, before continuing.

This function is useful for applications that do not use Windows GDI API to render text. For example, Internet Explorer uses DirectWrite API for text rendering.

The xpos, ypos are relative to the ICA client .


  • OCR should not be used for text that is small.

  • Known issue: The OCR engine removes the spaces from the recognized text.

Return Values

Citrix ICA Return Values


No parameterization is available for this function.


In this example, ctrx_sync_on_text_ocr causes script execution to pause until text "test" appears at the specified location in Notepad window.

ctrx_sync_on_text_ocr(304, 119, 30, 15, "test", "snapshot_109", "Appear", CTRX_LAST);
ctrx_obj_mouse_click("<class=Notepad>", 310, 125, 
     LEFT_BUTTON, 0, "Untitled - Notepad=snapshot_110",