SapGuiSetActiveWindow Function

Action

Sets the active window for the virtual users. Any subsequent SapGui calls will be performed on the active window. This function also allows window title verifications.

Include file

SapGui.bdh

Syntax

SapGuiSetActiveWindow( in sWindowId : string,
                       in sCaption  : string optional,
                       in nMatch    : number optional ) : boolean;
Parameter Description
sWindowId Id uniquely identifying the window to be set as the active one.
sCaption Caption of the window. This parameter will be used to perform a window title verification. The caption may also be provided using wildcards or regular expressions. How the function will evaluate the caption has to be specified in the third parameter of the function.
nMatch

Method how to perform the title verification. Available options are:

  • SAPGUI_MATCH_Exact. The function will report an error unless the caption parameter exactly matches the current window title. This method is the default behaviour when omitting this parameter.
  • SAPGUI_MATCH_ExactNoCase. Performs a case insensitive window title verification
  • SAPGUI_MATCH_Wildcard. Performs a window title verification using wildcards. The search string may contain '*' which matches 0 to n characters. '?' will match exactly one character. Characters enclosed by square brackets ([ ]) will match one character from the set enclosed by the brackets.
  • SAPGUI_MATCH_WildcardNoCase. Same as the previous option but the comparison is performed case insensitive.
  • SAPGUI_MATCH_RegExp. The window title verification is performed using regular expressions. Specify a regualar expression for the caption parameter.

Return value

  • true if successful
  • false otherwise

Example

transaction TMain
  var
    sId : string;
  begin
    // Connecting to SAP
    sId := SapGuiOpenConnection(" /SAP_CODEPAGE=1100 /FULLMENU 10.5.2.198 0 /3");
    SapGuiSetActiveConnection(sId);
    SapGuiSetActiveSession("ses[0]");

    // SAP
    SapGuiSetActiveWindow("wnd[0]", "SAP", SAPGUI_MATCH_Exact);
    SapGuiSetActiveWindow("wnd[0]", "S.*P", SAPGUI_MATCH_RegExp);
    SapGuiSetActiveWindow("wnd[0]", "S?P", SAPGUI_MATCH_Wildcard);
    SapGuiWindowResize(117, 28, false);

    // Logon to SAP System
    // Before running a test you have to customize the password parameter!
    ThinkTime(5.3);
    SapGuiLogon("bcuser", "*******", "000", "");

    // Copyright
  end TMain;