Hi,
I have several questions
1. Is it possible to not traverse object tree each time i want to access specific field?
So far i use Object.children.item() and so on. But it seems that anyway SAP traverse all the elements.
I thought it would be more performant but after profiling it seems not.
How to avoid that? Keep some kind of cache to access elements directly
2. Some GUI events doesn’t work: Hit, Error.
I catch them from Session object (Session_Hit, etc).
CreateSession and DestroySession works just fine.
The idea is same as built-in recorder: listen to user events and record script but with different payload (trying to avoid continuous session.FindById... and make element names human-readable).
Thank you in advance!
Request clarification before answering.
Hello Conrad,
very interesting questions and a very interesting perspective.
1. I have never done a profiling of this kind. Here my example:
TStart = Timer()
For i = 1 To 100
session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = CStr(i)
Next
TEnd = Timer()
MsgBox CStr(TEnd - TStart) 'Result 0,8
Set Field = session.findById("wnd[0]/usr/txtRSYST-MANDT")
TStart = Timer()
For i = 1 To 100
Field.Text = CStr(i)
Next
TEnd = Timer()
MsgBox CStr(TEnd - TStart) 'Result 0,4
It's about twice as fast to work with objects instead of the findById with the ID.
Wow...
sandra.rossi and you give the answer, cache the UI element in an object. I don't know another way.
2. The hit event works with the following example.
Sub ses_Error(Sess, ErrID, Desc1, Desc2, Desc3, Desc4)
MsgBox(Desc1 & vbCrLf & Desc2 & vbCrLf & Desc3 & vbCrLf & Desc4)
End Sub
Sub ses_Hit(Sess, Comp, IObj)
MsgBox(IObj) 'Works perfect
End Sub
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
Set connection = application.Children(0)
Set session = connection.Children(0)
If IsObject(WScript) Then
WScript.ConnectObject session, "ses_"
End If
'-To use hit event it is necessary to set this property-----------------
session.findById("wnd[0]").ElementVisualizationMode = True
MsgBox "Press to end"
I can't simulate the error event, but I assume this code example works.
How do you simulate an access denial to a a SAP GUI ActiveX control in a running script?
Let us know your experience.
Best regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 10 | |
| 5 | |
| 5 | |
| 5 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.