CitrixWaitForWindowRestore Function

Action

This function waits until a window is restored (having previously been maximized). This function is used to synchronize subsequent user input after a window is restored through a user action (e.g. a mouse click).

When a restored window has a different size than is specified by the nWidth and nHeight parameters (size of the window during recording) the window is resized to the specified size (otherwise recorded user actions wouldn’t work). When the position of the newly created window is different than that specified by the nX and nY parameters (position of the window during recording) and the bForcePos parameter is set to true, the window is moved to the correct position. When the bForcePos parameter is omitted or set to false, profile settings (Citrix / General/ Force window position) dictate whether or not the window is moved.

In the case of a timeout, error reporting can be prohibited with the bNoError parameter.

Include file

CitrixAPI.bdh

Syntax

CitrixWaitForWindowRestore( in nWindow   : number,
                            in nX        : number optional,
                            in nY        : number optional,
                            in nWidth    : number optional,
                            in nHeight   : number optional,
                            in bForcePos : boolean optional,
                            in nTimeout  : number optional,
                            in bNoError  : boolean optional ) : boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
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 window at recording (optional). When this parameter is provided and either the bForcePos parameter or the global setting (profile setting / Citrix / General/ Force window position) is set to true, the window is moved to this position.
nY Y coordinate of the top margin of the window at recording (optional). When this parameter is provided and either the bForcePos parameter or the global setting (profile setting / Citrix / General/ Force window position) is set to true, the window is moved to this position.
nWidth The width of the window at recording (optional). When this parameter is provided the window is resized to this width.
nHeight The height of the window at recording (optional). When this parameter is provided, the window is resized to this height.
bForcePos See description of nX / nY (optional).
nTimeout Specifies the time in milliseconds to wait for the window to move to the correct position (optional). When this parameter is omitted or set to 0, the default timeout is used. The default value can be adjusted by profile settings ( Settings > Active Profile > Citrix > General > Synchronization timeout ) or an appropriate call to the CitrixSetOption function.
bNoError Set this parameter to true to prevent a timeout from raising an error. This is especially useful for controlling variable user reactions.

Example:

  transaction TMain
  var
  begin
    CitrixInit(640, 480);
    CitrixConnect("myserver", "myusername", "mypass", "mydomain", COLOR_16bit);
    CitrixWaitForLogon();
    hWnd6 := CitrixWaitForWindowCreation("ICA Seamless Host Agent", MATCH_Exact, 0x94C800C4, 0, 0, 390, 223);
    CitrixWaitForWindow(hWnd6, EVENT_Activate);
    CitrixWaitForWindowCreation("Program Manager");
    CitrixMouseClick(182, 195, hWnd6, MOUSE_ButtonLeft);
    CitrixWaitForWindow(hWnd6, EVENT_Destroy);
    ThinkTime(2.78);
    CitrixMouseDblClick(38, 22, DESKTOP, MOUSE_ButtonLeft);
    hWnd8 := CitrixWaitForWindowCreation("My Documents", MATCH_Exact, 0x16CF0000, 285, 31, 268, 205);
    CitrixWaitForWindow(hWnd8, EVENT_Activate);
    CitrixMouseClick(234, 11, hWnd8, MOUSE_ButtonLeft);
    CitrixWaitForWindowPos(hWnd8, -4, -4);
    CitrixWaitForWindowSize(hWnd8, 648, 460);
    CitrixMouseClick(614, 12, hWnd8, MOUSE_ButtonLeft);
    CitrixWaitForWindowRestore(hWnd8, -4, -4, 648, 460);
    CitrixWaitForWindowPos(hWnd8, 285, 31);
    CitrixWaitForWindowSize(hWnd8, 268, 205);
    CitrixMouseClick(258, 13, hWnd8, MOUSE_ButtonLeft);
    CitrixWaitForWindow(hWnd8, EVENT_Destroy);
    CitrixDisconnect();
  end TMain;