Class SapGuiHelper
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
Returns
GetLabel(string, int, int)
Returns the text of a label element.
public static string GetLabel(string id, int connection = 0, int session = 0)
Parameters
Returns
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
Returns
GetSessionInfo(int, int)
Returns information about the current session (system, client, user, TCode).
public static GuiSessionInfo GetSessionInfo(int connection = 0, int session = 0)
Parameters
Returns
GetStatusMessage(int, int)
Returns the status bar message from the main window.
public static string GetStatusMessage(int connection = 0, int session = 0)
Parameters
Returns
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
Returns
HasError(int, int)
Returns true if the last action produced an error message.
public static bool HasError(int connection = 0, int session = 0)
Parameters
Returns
PressBack(int, int)
Sends Back/F3 (VKey 3) to the main window.
public static void PressBack(int connection = 0, int session = 0)
Parameters
PressButton(string, int, int)
Presses a button by its ID.
public static void PressButton(string buttonId, int connection = 0, int session = 0)
Parameters
PressEnter(int, int)
Sends Enter (VKey 0) to the main window.
public static void PressEnter(int connection = 0, int session = 0)
Parameters
PressSave(int, int)
Sends Save/Ctrl+S (VKey 11) to the main window.
public static void PressSave(int connection = 0, int session = 0)
Parameters
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
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
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
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
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)