SapGuiSendVKey Function

Action

Sends a keyboard input event to the active window.

Include file

SapGui.bdh

Syntax

SapGuiSendVKey( in nKey : number) : boolean;
Parameter Description
nKey

The ordinal number of the key that should be sent to the active window. These are predefined constants for keys that can be sent to the active window:

  • SAPGUI_VKEY_ENTER
  • SAPGUI_VKEY_HELP
  • SAPGUI_VKEY_F2
  • SAPGUI_VKEY_BACK
  • SAPGUI_VKEY_F4
  • SAPGUI_VKEY_CANCEL
  • SAPGUI_VKEY_PAGEUP
  • SAPGUI_VKEY_PAGEDOWN

Otherwise pass the ordinal number of the keyboard event to be sent.

Return value

  • true if successful
  • false otherwise

Example

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

    // SAP
    SapGuiSetActiveWindow("wnd[0]", "SAP", SAPGUI_MATCH_Exact);
    SapGuiWindowAction(SAPGUI_WND_MAXIMIZE);
    ThinkTime(2.8);
    SapGuiSetText("usr/txtRSYST-BNAME", "ddic");

    // Logon to SAP System
    // Before running a test you have to customize the password parameter!
    SapGuiSetText("usr/pwdRSYST-BCODE", "********");
    SapGuiSetFocus("usr/pwdRSYST-BCODE");

    // caretPosition
    SapGuiSetProperty("usr/pwdRSYST-BCODE", "caretPosition", "7");
    SapGuiIgnoreError(SAPENGINE_STATUSBAR_CHANGED, SEVERITY_SUCCESS);
    SapGuiSendVKey(SAPGUI_VKEY_ENTER);

    // Copyright
    SapGuiSetActiveWindow("wnd[1]", "Copyright", SAPGUI_MATCH_Exact);
    SapGuiPressButton("tbar[0]/btn[0]");
  end TMain;