durs / node-activex

Node.JS Implementaion of ActiveXObject
MIT License
329 stars 62 forks source link

COM's properties not showing up #49

Closed shuufi closed 5 years ago

shuufi commented 5 years ago

Have done a number of Python-based application that automates certain processes in SAP via the SAP Scripting in the past. Trying to do similar via NodeJs/Winax.

In Python

import win32com
import win32com.client

app = win32com.client.Dispatch("Sapgui.ScriptingCtrl.1")        
conn = self.app.OpenConnection("SAP Connection String", True)
session = self.conn.Children(0) # Children is a property of Connection object.

In JS

require('winax');
var app = new ActiveXObject('Sapgui.ScriptingCtrl.1');
var conn = app.OpenConnection('[SAP Connection String]', true);
var session = conn.Children(0); // Trying to fetch the first Children, similar to step above.

The JS code will fail at the conn.Children(0) with error Error: DispInvoke: Children Type mismatch.. Why that's the case?

From VSCode debug conn inspect

Connection API conn API

Thank you. Appreciate some help here.

durs commented 5 years ago

Children is not a function, see properties and methods of var children = conn.Children; may be var child = conn.Children[0];

вт, 21 мая 2019 г. в 04:16, Shuufi Sapli notifications@github.com:

Done a number of Python-based application that automates certain processes in SAP via the SAP Scripting. Trying to do via NodeJs/Winax.

In Python

import win32com import win32com.client

app = win32com.client.Dispatch("Sapgui.ScriptingCtrl.1") conn = self.app.OpenConnection("SAP Connection String", True) session = self.conn.Children(0) # Children is a property of Connection object.

In JS

require('winax'); var app = new ActiveXObject('Sapgui.ScriptingCtrl.1'); var conn = app.OpenConnection('[SAP Connection String]', true); var session = conn.Children(0); // Trying to fetch the first Children, similar to step above.

The JS code will fail at the conn.Children(0) with error Error: DispInvoke: Children Type mismatch.. Why that's the case?

From VSCode debug [image: conn inspect] https://user-images.githubusercontent.com/3444352/58061518-09771780-7ba9-11e9-9b99-fa144e2294d4.PNG

Connection API [image: conn API] https://user-images.githubusercontent.com/3444352/58061525-14ca4300-7ba9-11e9-8cf8-be5f317e58fe.PNG

Thank you. Appreciate some help here.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/durs/node-activex/issues/49?email_source=notifications&email_token=AAEMMNONW45LJAHAS2KW6R3PWNEQXA5CNFSM4HOGR7H2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GU3D4CA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEMMNO3EYQZOOVZHQNF5GLPWNEQXANCNFSM4HOGR7HQ .

shuufi commented 5 years ago

Solved by using var session = conn.Children[0];. Great, thanks for the help, and the package!

dxkirt3 commented 4 years ago

Hi I have tried this solution.

It's currently working with and been able to open and connect to SAP.

However, since it's using class object sapgui.scriptingctrl.1 it is opening an instance with different UI (this UI, I believe is opened when you directly connect to the server) there's too many missing buttons and all.

There's a working one using VBScript which is to getObject("SAPGUI"). However, when I tried. var app = new ActiveXObject("SAPGUI");

I received this error: Error: CreateInstance: SAPGUI Invalid class string

I'm not sure if it's related to different of new activeXObject vs getObject as the latter is more of attaching to current running objects?

dxkirt3 commented 4 years ago

I was able to work it out, by enabling the missing buttons and fields in the accessibility.

Thank you :)