View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0017617 | MMW 5 | Extensions framework | public | 2021-03-02 21:06 | 2021-03-16 20:25 |
Reporter | zvezdan | Assigned To | |||
Priority | none | Severity | minor | Reproducibility | have not tried |
Status | new | Resolution | open | ||
Summary | 0017617: Using COM objects in JavaScript | ||||
Description | I know it is possible using ActiveX/COM objects in JScript, but not in JavaScript. Could you add support for COM objects? Or is it already added? | ||||
Tags | No tags attached. | ||||
Fixed in build | |||||
|
By the way, this line in your vbs2js converter is useless: arrVBStoJS.push(new Array('[\\s]*(Server.)*CreateObject\\("', ' new ActiveXObject("')); ActiveXObject is supported only in JScript, not JavaScript. |
|
Good question. I'm doubtful that it is currently possible, since the COM model is Windows-only (and the goal is to make MM5 cross platform), but there might be a way to access it via js. Petr will be able to answer. And thank you for mentioning that about the ActiveXObject; I think the VBStoJS project still needs quite a bit of work, so I'm noting that for when we get back to work on it. |
|
Could this be possible if you somehow integrate Node.js (Electron, NW.js) + node-activex into the program? |
|
I would guess that MM5 is too far in its development to introduce a new framework - after all, it's very close to its initial release. If they (Jiri and Petr?) decide to add COM access via JS, it would make more sense to do it via a native method in the "app" object. My guess as to why it's not done is because they spent a lot of work to make sure all the functionality can be achieved through JS methods (to enable cross-platform). There can also be ways around it, though, if you have an external program that accesses MM5's COM. There's a new method, runJSCode, which can let you invoke methods from within MM5. So you could have a "normal" (JS) addon that introduces additional methods to the global window object, and you can invoke them with runJSCode. For example, you can define a function window.runJSCode_callback in an addon, and then you can invoke it with: SDB.runJSCode("(()=>{runJSCode_callback('This was sent by a VB Script!')})();", True) |
|
I'm pretty sure we will not integrate Node.js or similar 3rd party framework. |
|
I don't need any 3rd party framework. I just need what I asked for in the Summary: to use COM objects in JavaScript from inside MM. Which is not the same as using MM5 through its COM from an external application and cannot be substituted with that. |
|
I've assigned to Jiri for a feedback, but i think we will not add any additional COM support. |
|
Zvezdan, to clarify, I suppose that you don't need to access native MM functionality over COM, but rather some third-party COM objects, right? |
|
Yes and no, I would like to have both. I want to access native MM functionality over COM from external application, and I want to access the third-party COM objects in JavaScript of my add-ons within MM. You have already implemented the first part, but I need the second part as well. |
|
If it is still unclear, here is an example that is possible in JScript and JavaScript with node-activex, but not with plain JavaScript: var xl = new ActiveXObject("Excel.Application"); which is an equivalent to this VBScript: Set xl = CreateObject("Excel.Application") |
|
We looked into it with Petr and generally speaking it is possible to implement ActiveX support. We'll see whether we could get it into MM5.1. That said, plain JS implementations would be preferred. I wonder whether there are cases where ActiveX support is critically needed? In the mentioned case of Excel, there's quite a lot of free JS implementations that should be able to replace Excel at least for basic work (http://slickgrid.net/, https://github.com/jspreadsheet/ce or https://github.com/myliang/x-spreadsheet, the exact choice would probably depend on the exact needs). |
|
Thanks for the links. I mentioned Excel just as a popular example, which is (was) used even in your own Export.vbs script. I think that I read in Forum long time ago that someone was using Excel from MM in that way as well. Keep in mind that there are users writing MM scripts for their own personal use, which are not published anywhere. I estimate that the number of such scripts is the same or even more than the published ones. I am sure that many Windows users have a need for different COM objects in their scripts that cannot be found in any free JavaScript implementations. |