;-Begin-----------------------------------------------------------------
;-Directives----------------------------------------------------------
AutoItSetOption("MustDeclareVars", 1)
;-Function GetSessionOfSID--------------------------------------------
;-
;- Delivers the first non busy session of a SID
;-
;---------------------------------------------------------------------
Func GetSessionOfSID($Application, $SID)
;-Local Variables-------------------------------------------------
Local $i, $Connection, $j, $Session, $SessionInfo
If $Application.Children.Count > 0 Then
For $i = 0 To $Application.Children.Count - 1
$Connection = $Application.Children($i)
For $j = 0 To $Connection.Children.Count - 1
If $Connection.Children($j).Busy = False Then
$Session = $Connection.Children($j)
$SessionInfo = $Session.Info
If $SessionInfo.SystemName = $SID Then
Return $Session
EndIf
EndIf
Next
Next
EndIf
EndFunc
;-Sub Main------------------------------------------------------------
Func Main()
;-Local Variables-------------------------------------------------
Local $SAPROT, $SapGuiAuto, $Application, $Session
$SAPROT = ObjCreate("SapROTWr.SAPROTWrapper")
If Not IsObj($SAPROT) Then
Return
EndIf
$SapGuiAuto = $SAPROT.GetROTEntry("SAPGUI")
If Not IsObj($SapGuiAuto) Then
Return
EndIf
$Application = $SapGuiAuto.GetScriptingEngine()
If Not IsObj($Application) Then
Return
EndIf
$Session = GetSessionOfSID($Application, "NSP")
If IsObj($Session) Then
;Your script code here
MsgBox(0, "", $Session.Id)
EndIf
$Application = 0
$SapGuiAuto = 0
$SAPROT = 0
EndFunc
;-Main----------------------------------------------------------------
Main()
;-End-------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
10 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |