CitrixWaitForWindow Function

Action

This function waits until a specified window event (specified with the nEvent parameter) occurs. Such events may be an activation, destruction or caption change of a specified window. If a selected event is a caption change, any caption change of the specified window will satisfy the function. Additionally a caption can be specified explicitly using the sCaption and nMatch parameters. See CitrixWaitForWindowCreation for a detailed description of these two parameters.

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

Include file

CitrixAPI.bdh

Syntax

CitrixWaitForWindow( in nWindow  : number,
                     in nEvent   : number optional,
                     in sCaption : number optional,
                     in nMatch   : number 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.
nEvent

Specify one of the following values (optional):

  • EVENT_Activate (default): Waits for the activation of the specified window.

  • EVENT_Destroy: Waits for the destruction (close) of the specified window.

  • EVENT_CaptionChange: Waits for the caption change of the specified window. When this option is specified, the next two parameters can be used to explicitly specify a caption.

sCaption Window caption to wait for. When the nEvent parameter is not EVENT_CaptionChange, this parameter is ignored. When this parameter is omitted (or “” is used), this function waits for the next caption change of the window.
nMatch

When the nEvent parameter is not EVENT_CaptionChange, this parameter is ignored (optional).Specify one of the following values:

  • MATCH_Exact (default): Case-sensitive comparison.
  • MATCH_ExactNoCase: Case-insensitive comparison.
  • MATCH_Wildcard: The search string must either begin or end with a '*' character, which matches everything. The rest of the string is compared case sensitively.
  • MATCH_WildcardNoCase: The search string must either begin or end with a '*' character, which matches everything. The rest of the string is compared case insensitively.
  • MATCH_RegExp: The search string is a regular expression. See the regular expression chapter for a description of Silk Performer's regular expression capability.
nTimeout Specifies the time in milliseconds to wait for the specified event (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();
    hWnd4 := CitrixWaitForWindowCreation("", MATCH_Exact, 0x96840000, -2, 452, 644, 30);
    hWnd5 := CitrixWaitForWindowCreation("ICA Seamless Host Agent", MATCH_Exact, 0x94C800C4, 0, 0, 390, 223);
    CitrixWaitForWindow(hWnd5, EVENT_Activate);
    CitrixWaitForWindowCreation("Program Manager");
    ThinkTime(3.33);
    CitrixMouseClick(208, 193, hWnd5, MOUSE_ButtonLeft);
    CitrixWaitForWindow(hWnd5, EVENT_Destroy);
    ThinkTime(2.45);
    CitrixMouseClick(41, 7, hWnd4, MOUSE_ButtonLeft);
    hWnd7 := CitrixWaitForWindowCreation("", MATCH_Exact, 0x96400000, 2, 193, 163, 263);
    CitrixMouseClick(48, 250, hWnd7, MOUSE_ButtonLeft);
    CitrixWaitForWindow(hWnd7, EVENT_Destroy);
    hWnd9 := CitrixWaitForWindowCreation("Shut Down Windows", MATCH_Exact, 0x94C808CC, 111, 96, 417, 192);
    CitrixWaitForWindow(hWnd9, EVENT_Activate);
    CitrixMouseClick(184, 165, hWnd9, MOUSE_ButtonLeft);
    CitrixWaitForDisconnect();
  end TMain;