CitrixSearchWindow Function

Action

The opposite of the CitrixWaitForWindowCreation function, this function does not wait until a specified window appears; this function searches all tracked windows for a suitable window. A window may be specified by its caption, whereas five different search options may be provided with the nMatch parameter. If the function succeeds it returns a window handle that can be used as the nWindow parameter in Citrix functions.

Include file

CitrixAPI.bdh

Syntax

CitrixSearchWindow( in sCaption : string,
                    in nMatch   : number optional ): number;

Return value

  • >0 if the function succeeds

  • 0 otherwise

Parameter Description
sCaption Caption of the window to search for.
nMatch

Specify one of the following values (optional):

  • 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.

Example:

  transaction TMain
  var
    nWindowSearchHandle : number;
    sWindowName         : string;
  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);
    nWindowSearchHandle := CitrixSearchWindow("My D*", MATCH_Wildcard);
    CitrixGetWindowCaption(nWindowSearchHandle, sWindowName);
    print("window " + string(nWindowSearchHandle)
                      + "; name: " + sWindowName);
    CitrixMouseClick(258, 13, hWnd8, MOUSE_ButtonLeft);
    CitrixWaitForWindow(hWnd8, EVENT_Destroy);
    CitrixDisconnect();
  end TMain;