Table of Contents

Class GuiApplication

Namespace
SapGui.Wrapper
Assembly
SapGui.Wrapper.dll

Entry point. Represents the running SAP GUI application. Equivalent to the VBA GuiApplication object obtained via SapROTWr.CSapROTWrapper.GetROTEntry("SAPGUI").GetScriptingEngine().

public class GuiApplication : GuiComponent
Inheritance
GuiApplication
Inherited Members

Properties

ActiveSession

Returns the currently focused (active) GuiSession. Equivalent to the VBA application.ActiveSession shortcut.

public GuiSession ActiveSession { get; }

Property Value

GuiSession

Exceptions

InvalidOperationException

Thrown when SAP reports no active session.

ConnectionCount

Number of active server connections.

public int ConnectionCount { get; }

Property Value

int

Version

SAP GUI version string, e.g. "750" or "760".

public string Version { get; }

Property Value

string

Methods

Attach()

Attaches to the currently running SAP GUI instance. SAP GUI must be open and scripting must be enabled.

public static GuiApplication Attach()

Returns

GuiApplication

Exceptions

SapGuiNotFoundException

GetConnections()

Returns all active server connections.

public IReadOnlyList<GuiConnection> GetConnections()

Returns

IReadOnlyList<GuiConnection>

GetFirstConnection()

Gets the first available connection (convenience helper).

public GuiConnection GetFirstConnection()

Returns

GuiConnection

GetFirstSession()

Gets the first session of the first connection (convenience helper). Equivalent to the VBA one-liner: application.Children(0).Children(0)

public GuiSession GetFirstSession()

Returns

GuiSession

OpenConnection(string, bool)

Opens a connection to an SAP system described by description (the system entry name as configured in the SAP Logon Pad). Equivalent to the VBA application.OpenConnection(description).

After calling this method, use GetConnections() or ActiveSession to obtain a usable GuiSession.

public GuiConnection OpenConnection(string description, bool sync = true)

Parameters

description string

The SAP Logon Pad system entry name, e.g. "PRD - Production".

sync bool

When true (default), the call blocks until the logon screen is ready. Pass false for asynchronous open.

Returns

GuiConnection

The newly opened GuiConnection.