CitrixGetScreen Function


Takes a screenshot of the selected region and writes the screenshot to a file in the result directory. The file name can be provided by the first parameter. If the file name is omitted, it will be automatically generated by the user ID and hash value of the image. Use the optional sOutFile parameter to get the generated file name.

The screen region can be specified absolutely or relatively to a window (by specifying a window handle). When only a window handle and no position or size is provided, the region specified by the window outline is used. CitrixGetScreen without any parameter takes a screenshot of the entire screen and saves it to a file that’s name is a concatenation of the calling user and the hash value of the current screen.

Note: CitrixGetScreen can only be called in Normal Mode (see CitrixInit). If used in Fast Mode, an error will be raised.

Include file



CitrixGetScreen( in  sFile    : string optional,
                 in  nWindow  : number optional,
                 in  nX       : number optional,
                 in  nY       : number optional,
                 in  nWidth   : number optional,
                 in  nHeight  : number optional,
                 out sOutFile : string optional ) : boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
sFile Name of the file, which is stored in the result directory (optional). When this parameter is omitted the filename is generated automatically using the hash value of the image.
nWindow Window handle returned by a call to CitrixWaitForWindowCreation. Use DESKTOP or omit this parameter to specify a region relative to the desktop (or the entire desktop).
nX X coordinate of the left margin of the screen region (optional).
nY Y coordinate of the top margin of the screen region (optional).
nWidth Width of the region (optional). Omit this parameter to take a screen shot of the entire window.
nHeight Height of the region (optional). Omit this parameter to take a screenshot of the entire window.
sOutFile Returns the name of the written file (optional).


  transaction TMain
    CitrixInit(640, 480);
    CitrixConnect("citserver", "user", "password", "companydomain", COLOR_16bit);
    hWnd6 := CitrixWaitForWindowCreation("ICA Seamless Host Agent", MATCH_Exact, 0x94C800C4, 0, 0, 390, 223);
    CitrixWaitForWindow(hWnd6, EVENT_Activate);
    CitrixWaitForWindowCreation("Program Manager");
    CitrixMouseClick(214, 197, hWnd6, MOUSE_ButtonLeft);
    CitrixWaitForWindow(hWnd6, EVENT_Destroy);
    CitrixMouseDblClick(112, 16, DESKTOP, MOUSE_ButtonLeft);
    hWnd9 := CitrixWaitForWindowCreation("Microsoft Excel – Book*", MATCH_Wildcard, 0x15CF0000, -4, -4, 648, 460);
    CitrixGetScreen("screenshot01.bmp", hWnd9, 10, 20, 100, 100);
    CitrixMouseClick(634, 9, hWnd9, MOUSE_ButtonLeft);    CitrixWaitForWindow(hWnd9, EVENT_Destroy);
  end TMain;