Scripts plugin
- Author
- Message
-
Offline
- Posts: 1949
- Joined: Sat Mar 06, 2010 7:40 pm
- Location: Poland
Instructor
This sample script creates WebBrowser control using Atl.dll library:
How to get ActiveX object (WebBrowser object) to be able to use its methods, properties and events described here: WebBrowser object?
This sample script creates WebBrowser control using Atl.dll library:
How to get ActiveX object (WebBrowser object) to be able to use its methods, properties and events described here: WebBrowser object?
-
Offline
- Posts: 2247
- Joined: Tue Aug 07, 2007 2:03 pm
- Location: Vinnitsa, Ukraine
KDJ
I expect you want you this API. Well, I have no experience using it, maybe it is possible. But:
Short answer - FORGET IT. It is impossible to do now in JScript environment.
Long answer - Web Browser Control(as well as Windows Media Player, Data Grids, Flash player, and some other useful objects) is ActiveX Control. What that means? That means:
1. You can instantiate it using built-in into JScript engine object of type ActiveXObject, which is proxy object bound to default interface of requested ActiveX Component. It works for JScript because MS made it possible. Methods of dispinterface are transparently propagated as methods of returned object. (dispinterface is synonym for "COM interface derived from base interface IDispatch").
Example of successful usage of ActiveX Object - spellchecker using Microsoft Word (ActiveX object named "Word.application").
2. ActiveX Control. That means, id client code want work with ActiveX Controls, he MUST provide proper environment. These requirements include a number of steps which must be performed before Control become usable and fully functional. These steps includes "putting" Control into Ole Container, Activating it, etc. And here we have problems: there is no tools in JScript to do that. [["putting" Control into Ole Container]] involves implementing special COM interfaces like: IOleClientSite, IOleWindow, IOleInPlaceSite, and querying some other interface from Control. The thing is - all those interfaces are not derived from IDispatch, they are derived from IUnknown directly, so is impossible in JScript. And even in plain C/C++ it requires deep understanding of technology. In C++ world MS provides us with helper libraries: ATL and MFC, but not for JScript.
You can find more info on MSDN, Sample implementation of that "environment" you can find here.
I see one possible solution suitable: we need to implementation of "environment" elsewhere: it can be other ActiveX Object, or special implementation provided by plugin itself(by Instructor).
Maybe I wrong?
I expect you want you this API. Well, I have no experience using it, maybe it is possible. But:
Short answer - FORGET IT. It is impossible to do now in JScript environment.
Long answer - Web Browser Control(as well as Windows Media Player, Data Grids, Flash player, and some other useful objects) is ActiveX Control. What that means? That means:
1. You can instantiate it using built-in into JScript engine object of type ActiveXObject, which is proxy object bound to default interface of requested ActiveX Component. It works for JScript because MS made it possible. Methods of dispinterface are transparently propagated as methods of returned object. (dispinterface is synonym for "COM interface derived from base interface IDispatch").
Example of successful usage of ActiveX Object - spellchecker using Microsoft Word (ActiveX object named "Word.application").
2. ActiveX Control. That means, id client code want work with ActiveX Controls, he MUST provide proper environment. These requirements include a number of steps which must be performed before Control become usable and fully functional. These steps includes "putting" Control into Ole Container, Activating it, etc. And here we have problems: there is no tools in JScript to do that. [["putting" Control into Ole Container]] involves implementing special COM interfaces like: IOleClientSite, IOleWindow, IOleInPlaceSite, and querying some other interface from Control. The thing is - all those interfaces are not derived from IDispatch, they are derived from IUnknown directly, so is impossible in JScript. And even in plain C/C++ it requires deep understanding of technology. In C++ world MS provides us with helper libraries: ATL and MFC, but not for JScript.
You can find more info on MSDN, Sample implementation of that "environment" you can find here.
I see one possible solution suitable: we need to implementation of "environment" elsewhere: it can be other ActiveX Object, or special implementation provided by plugin itself(by Instructor).
Maybe I wrong?
-
Offline
- Site Admin
- Posts: 6311
- Joined: Thu Jul 06, 2006 7:20 am
Добавлено: возможность вызова функции по адресу в метод oSys.Call.
Added: possibility to call function by address in oSys.Call method.
Scripts plugin v17.7
Added: possibility to call function by address in oSys.Call method.
Scripts plugin v17.7
-
Offline
- Posts: 1949
- Joined: Sat Mar 06, 2010 7:40 pm
- Location: Poland
-
Offline
- Posts: 2247
- Joined: Tue Aug 07, 2007 2:03 pm
- Location: Vinnitsa, Ukraine
KDJ
1. Technically IID == CLSID == UUID == GUID - an identifier. In world of COM all entities are identified by GUID identifier, which is 16-byte sized value(byte array). You can observe those in registry, for instance HKEY_CLASSES_ROOT\CLSID\{00000100-0000-0010-8000-00AA006D2EA4}
Difference between IID and CLSID and other *ID - its just hints for developer what kind of entity this GUID identifies.
There are such kind of entities:
IID - Interface identifier
CLSID - COM Object(Class) identifier
TLBID - Type Library identifier(metadata library)
(moreover, in Windows, drivers are expose their functionality using such Intreface ID)
All operations in world of COM are performed using such IDs.
If you want ask COM to create some object, you must provide its CLSID value. Moreover, CLSID is identifier of concrete class. But interaction with objects are done using COM Interfaces. COM Interface Definition consists of ordered list of methods(functions) and its signature(parameter types) that can be used by clients. An Unique IID value is assigned to each COM Interface Definition. Once COM Interface Definition desires to changed count, order of methods, or any of its parameters, it cannot use old IID, it MUST use other IID. So as second argument you provide COM with IID of interface you will interact with requested object.
See MSDN CoCreateInstance
IID {D30C1661-CDAF-11d0-8A3E-00C04FC9E26E} is assigned to interface IWebBrowser2. In Windows SDK we refer this constant value as IID_IWebBrowser.
But you can note: it is pretty hard to remember such 16-byte IDs.
For this reason MS introduced another one kind of ID - ProgId. It is human readable label of CLSID value. CLISD value of Web Browser Control is {8856F961-340A-11D0-A96B-00C04FD705A2} (in Windows SDK referred usually as CLSID_WebBrowser constant). There is exits ProgId which refers this value - "Shell.Explorer.2". JScript class ActiveXObject accepts both ProgIds and CLSIDs. Dictionary of ProgIds is stored in Windows Registry(HKEY_CLASSES_ROOT).
2. Yes, they all are. vTable - Virtual Functions Table - is core if Object-Oriented Paradigm. It is array of pointers(addresses) to functions in memory. In technical aspect COM Interface Definition is vTable structure.
3. Remember what I said in (1) "interaction with objects are done using COM Interfaces". In terminology of ActiveX Event - actually callback interface(dispinterface). Event interface must be implemented by client(i.e. you must create and fill vTable structure). Instance of such implantation must be given(registered) to object, and only in this case objects itself will invoke methods of event interface - Fire event.
It was brief explanation. I strongly recommend you read information about COM, ActiveX and practice it on C/C++(C++ easier to use, but harder to understand low-level details; C harder to use, but here in JScript it will be even harder). Well, I can say, I did not met good implementation of non-trivial interfaces on C yet. Well, you can look how interfaced used in C in sources of Scripts plugin and Speech plugin
1. Technically IID == CLSID == UUID == GUID - an identifier. In world of COM all entities are identified by GUID identifier, which is 16-byte sized value(byte array). You can observe those in registry, for instance HKEY_CLASSES_ROOT\CLSID\{00000100-0000-0010-8000-00AA006D2EA4}
Difference between IID and CLSID and other *ID - its just hints for developer what kind of entity this GUID identifies.
There are such kind of entities:
IID - Interface identifier
CLSID - COM Object(Class) identifier
TLBID - Type Library identifier(metadata library)
(moreover, in Windows, drivers are expose their functionality using such Intreface ID)
All operations in world of COM are performed using such IDs.
If you want ask COM to create some object, you must provide its CLSID value. Moreover, CLSID is identifier of concrete class. But interaction with objects are done using COM Interfaces. COM Interface Definition consists of ordered list of methods(functions) and its signature(parameter types) that can be used by clients. An Unique IID value is assigned to each COM Interface Definition. Once COM Interface Definition desires to changed count, order of methods, or any of its parameters, it cannot use old IID, it MUST use other IID. So as second argument you provide COM with IID of interface you will interact with requested object.
See MSDN CoCreateInstance
IID {D30C1661-CDAF-11d0-8A3E-00C04FC9E26E} is assigned to interface IWebBrowser2. In Windows SDK we refer this constant value as IID_IWebBrowser.
But you can note: it is pretty hard to remember such 16-byte IDs.
For this reason MS introduced another one kind of ID - ProgId. It is human readable label of CLSID value. CLISD value of Web Browser Control is {8856F961-340A-11D0-A96B-00C04FD705A2} (in Windows SDK referred usually as CLSID_WebBrowser constant). There is exits ProgId which refers this value - "Shell.Explorer.2". JScript class ActiveXObject accepts both ProgIds and CLSIDs. Dictionary of ProgIds is stored in Windows Registry(HKEY_CLASSES_ROOT).
2. Yes, they all are. vTable - Virtual Functions Table - is core if Object-Oriented Paradigm. It is array of pointers(addresses) to functions in memory. In technical aspect COM Interface Definition is vTable structure.
3. Remember what I said in (1) "interaction with objects are done using COM Interfaces". In terminology of ActiveX Event - actually callback interface(dispinterface). Event interface must be implemented by client(i.e. you must create and fill vTable structure). Instance of such implantation must be given(registered) to object, and only in this case objects itself will invoke methods of event interface - Fire event.
It was brief explanation. I strongly recommend you read information about COM, ActiveX and practice it on C/C++(C++ easier to use, but harder to understand low-level details; C harder to use, but here in JScript it will be even harder). Well, I can say, I did not met good implementation of non-trivial interfaces on C yet. Well, you can look how interfaced used in C in sources of Scripts plugin and Speech plugin
-
Offline
- Posts: 1949
- Joined: Sat Mar 06, 2010 7:40 pm
- Location: Poland