Table of Contents

Class SapGuiHelper

Namespace
SapGui.Wrapper
Assembly
SapGui.Wrapper.dll

Convenience helper with static, dependency-free methods designed for use in UiPath Invoke Code and Code Activity activities.

All methods perform a fresh Attach() on every call, which is safe for UiPath workflows where the activity runs in a single-threaded activity context without keeping state between activities.

Example (UiPath Invoke Code – VB.NET):

' Set a text field
SapGuiHelper.SetText("wnd[0]/usr/txtRSYST-BNAME", "myuser")

' Read a text field Dim val As String = SapGuiHelper.GetText("wnd[0]/usr/txtRSYST-BNAME")

' Press Enter SapGuiHelper.PressEnter()

' Start a transaction SapGuiHelper.StartTransaction("MM60")

public static class SapGuiHelper
Inheritance
SapGuiHelper
Inherited Members

Methods

FindById(string, int, int)

Finds any component by ID and returns it as a GuiComponent. Cast to the specific type when you need type-specific members.

public static GuiComponent FindById(string id, int connection = 0, int session = 0)

Parameters

id string
connection int
session int

Returns

GuiComponent

GetLabel(string, int, int)

Returns the text of a label element.

public static string GetLabel(string id, int connection = 0, int session = 0)

Parameters

id string
connection int
session int

Returns

string

GetSession(int, int)

Attaches to the running SAP GUI and returns the specified session. The SapGuiClient is disposed after the call; this is safe because the underlying COM session object remains alive inside SAP GUI.

public static GuiSession GetSession(int connection = 0, int session = 0)

Parameters

connection int
session int

Returns

GuiSession

GetSessionInfo(int, int)

Returns information about the current session (system, client, user, TCode).

public static GuiSessionInfo GetSessionInfo(int connection = 0, int session = 0)

Parameters

connection int
session int

Returns

GuiSessionInfo

GetStatusMessage(int, int)

Returns the status bar message from the main window.

public static string GetStatusMessage(int connection = 0, int session = 0)

Parameters

connection int
session int

Returns

string

GetText(string, int, int)

Reads the Text property of a text field.

public static string GetText(string fieldId, int connection = 0, int session = 0)

Parameters

fieldId string
connection int
session int

Returns

string

HasError(int, int)

Returns true if the last action produced an error message.

public static bool HasError(int connection = 0, int session = 0)

Parameters

connection int
session int

Returns

bool

PressBack(int, int)

Sends Back/F3 (VKey 3) to the main window.

public static void PressBack(int connection = 0, int session = 0)

Parameters

connection int
session int

PressButton(string, int, int)

Presses a button by its ID.

public static void PressButton(string buttonId, int connection = 0, int session = 0)

Parameters

buttonId string
connection int
session int

PressEnter(int, int)

Sends Enter (VKey 0) to the main window.

public static void PressEnter(int connection = 0, int session = 0)

Parameters

connection int
session int

PressSave(int, int)

Sends Save/Ctrl+S (VKey 11) to the main window.

public static void PressSave(int connection = 0, int session = 0)

Parameters

connection int
session int

SendVKey(int, int, int)

Sends a virtual key to the main window.

public static void SendVKey(int vKey, int connection = 0, int session = 0)

Parameters

vKey int
connection int
session int

SetCheckBox(string, bool, int, int)

Sets the state of a check box.

public static void SetCheckBox(string id, bool selected, int connection = 0, int session = 0)

Parameters

id string
selected bool
connection int
session int

SetComboBox(string, string, int, int)

Sets the key of a combo box.

public static void SetComboBox(string id, string key, int connection = 0, int session = 0)

Parameters

id string
key string
connection int
session int

SetText(string, string, int, int)

Sets the Text property of a text field.

public static void SetText(string fieldId, string value, int connection = 0, int session = 0)

Parameters

fieldId string
value string
connection int
session int

StartTransaction(string, int, int)

Enters a transaction code (types it in the command field and presses Enter).

public static void StartTransaction(string tCode, int connection = 0, int session = 0)

Parameters

tCode string
connection int
session int