on 2022 Nov 01 2:11 AM
Dear all.
We use python call sap gui scriping to do some rpa work, and it worked very well in majority associations,but when we use python to bind event of application , there is a problem .
The bellow code we tested in VBS and it runed well.
Dim objSapGui
Set objSapGui = GetObject("SAPGUI")
Dim objScriptingEngine
Set objScriptingEngine = objSapGui.GetScriptingEngine
WScript.ConnectObject objScriptingEngine, "Engine_"
Dim Waiting
Waiting = 1
Do While (Waiting = 1)
WScript.Sleep(100)
Loop
Set objScriptingEngine = Nothing
Set objSapGui = Nothing
Sub Engine_CreateSession(ByVal Session)
Dim result
result = MsgBox("Session created", vbOKCancel)
If result = vbCancel then
Waiting = 0
End If
End Sub
But when we ran bellow code in python, there turned up with an error: AssertionError
assert enumEntry.desc.desckind == pythoncom.DESCKIND_FUNCDESC
import win32com.client
class Events:
def __init__(self):
pass
appl = win32com.client.GetObject("SAPGUI").GetScriptingEngine
event = win32com.client.WithEvents(appl, Events)
I have tested that win32com.client.WithEvents by Excel and it runs well.
excel = win32com.client.Dispatch("Excel.Application")
win32com.client.WithEvents(excel, SessionEvents)
Do you have any successful example aboout binding sap gui scripting event by python?
Thanks!
Request clarification before answering.
User | Count |
---|---|
59 | |
10 | |
8 | |
8 | |
6 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.