QSA-interest Archive, August 2005
activex objects scripting
Message 1 in thread
Could you please tell me if it is possible to script activex objects in the
current version or in the next one?
I am looking at whether it is possible to have code like the one below. Or
I should say more or less similar, but the bottom line is that the activex
object methods or properties should be specified using the syntax
<objectName>.<propertyName> or <objectName>.<methodName>(<param1>, <param2>)
and not <objectName>.invoke("<methodName>", <param1>, <param2>):
var ExcelSheet;
ExcelApp = new ActiveXObject("Excel.Application");
ExcelSheet = new ActiveXObject("Excel.Sheet");
ExcelSheet.Application.Visible = true;
ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
I know that QSA is used to provide the means to easily script applications
using Qt, but in addition to this I need to be able to script activex
objects, and the question is does QSA support it in the same way as JScript
does?
If it doesn't, then I might as well use JScript and make activeX objects out
of my Qt script objects (crossplatform is not an issue for now).
Thank you
Message 2 in thread
"B.C." <bikerc@xxxxxxxxx> wrote in message
news:ddedco$4p2$1@xxxxxxxxxxxxxxxxxxxxx
> Could you please tell me if it is possible to script activex objects in
the
> current version or in the next one?
>
> I am looking at whether it is possible to have code like the one below.
Or
> I should say more or less similar, but the bottom line is that the
activex
> object methods or properties should be specified using the syntax
> <objectName>.<propertyName> or <objectName>.<methodName>(<param1>,
<param2>)
> and not <objectName>.invoke("<methodName>", <param1>, <param2>):
>
> var ExcelSheet;
> ExcelApp = new ActiveXObject("Excel.Application");
> ExcelSheet = new ActiveXObject("Excel.Sheet");
> ExcelSheet.Application.Visible = true;
> ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
>
> I know that QSA is used to provide the means to easily script
applications
> using Qt, but in addition to this I need to be able to script activex
> objects, and the question is does QSA support it in the same way as
JScript
> does?
>
> If it doesn't, then I might as well use JScript and make activeX objects
out
> of my Qt script objects (crossplatform is not an issue for now).
If you have your COM object wrapped in a QAxObject, then you should be
able to just add it to QSA and access the API through QSA.
http://doc.trolltech.com/3.3/qaxobject.html
Alternatively you can use the QAxScript* classes to have the Windows
Scripting Host automate your object.
http://doc.trolltech.com/3.3/qaxscriptmanager.html
Volker
Message 3 in thread
Hi, Volker:
Thank you for your answer. One more question. I looked at the spec for
qaxobject. While in JScript you can have:
ExcelSheet = new ActiveXObject("Excel.Sheet");
ExcelSheet.Applicable.Visible=true
in QSA you would write this (if you were to expose QAxObject api to qsa):
1. ExcellSheet = new QAxObject(0, "Excel.Sheet");
2. ExcelSheet.querySubObject("Applicable").dynamicCall( "Visible", true);
(correct me if I am wrong here)
I want to use the same syntax as in JScript for line 2. Is there a way to do
this, and behind the scenes the QSA engine would invoke these calls, that
is:
the statement ExcelSheet.Applicable.Visible=true gets translated
automatically by the engine in
ExcelSheet->querySubObject("Applicable")->dynamicCall( "Visible", true);
All these COM objects implement IDispatch and the information about their
methods, method parameters, properties can be queried at runtime. So I was
thinking maybe, there is a way to feed this information as metadata
information to the script engine and this way I would be able to use the
same syntax as in JScript What do you think, is it possible?
Thanks
"Volker Hilsheimer" <unwatched@xxxxxxx> wrote in message
news:decmth$9v4$1@xxxxxxxxxxxxxxxxxxxxx
> "B.C." <bikerc@xxxxxxxxx> wrote in message
> news:ddedco$4p2$1@xxxxxxxxxxxxxxxxxxxxx
> > Could you please tell me if it is possible to script activex objects in
> the
> > current version or in the next one?
> >
> > I am looking at whether it is possible to have code like the one below.
> Or
> > I should say more or less similar, but the bottom line is that the
> activex
> > object methods or properties should be specified using the syntax
> > <objectName>.<propertyName> or <objectName>.<methodName>(<param1>,
> <param2>)
> > and not <objectName>.invoke("<methodName>", <param1>, <param2>):
> >
> > var ExcelSheet;
> > ExcelApp = new ActiveXObject("Excel.Application");
> > ExcelSheet = new ActiveXObject("Excel.Sheet");
> > ExcelSheet.Application.Visible = true;
> > ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
> >
> > I know that QSA is used to provide the means to easily script
> applications
> > using Qt, but in addition to this I need to be able to script activex
> > objects, and the question is does QSA support it in the same way as
> JScript
> > does?
> >
> > If it doesn't, then I might as well use JScript and make activeX objects
> out
> > of my Qt script objects (crossplatform is not an issue for now).
>
> If you have your COM object wrapped in a QAxObject, then you should be
> able to just add it to QSA and access the API through QSA.
>
> http://doc.trolltech.com/3.3/qaxobject.html
>
> Alternatively you can use the QAxScript* classes to have the Windows
> Scripting Host automate your object.
>
> http://doc.trolltech.com/3.3/qaxscriptmanager.html
>
> Volker
>
>
Message 4 in thread
B.C.-
Perhaps you can take advantage of QSA's ability to dynamically assign
functions as members of objects:
var myObj = new SomeKindOfObject; // Create an object
myObj.myFunction = function(x) { myObj.call( "myFunction", x } //
Create a dynamic function
myObj.myFunction(4); // will actually do myObj.call("myFunction", 4);
Maybe you could expand on that idea and write a function that inspects
an ActiveX object and creates member functions like that?
-Joel
On Aug 24, 2005, at 8:58 AM, B.C. wrote:
> Hi, Volker:
>
> Thank you for your answer. One more question. I looked at the spec for
> qaxobject. While in JScript you can have:
>
> ExcelSheet = new ActiveXObject("Excel.Sheet");
> ExcelSheet.Applicable.Visible=true
>
> in QSA you would write this (if you were to expose QAxObject api to
> qsa):
>
> 1. ExcellSheet = new QAxObject(0, "Excel.Sheet");
> 2. ExcelSheet.querySubObject("Applicable").dynamicCall( "Visible",
> true);
> (correct me if I am wrong here)
>
> I want to use the same syntax as in JScript for line 2. Is there a way
> to do
> this, and behind the scenes the QSA engine would invoke these calls,
> that
> is:
> the statement ExcelSheet.Applicable.Visible=true gets translated
> automatically by the engine in
> ExcelSheet->querySubObject("Applicable")->dynamicCall( "Visible",
> true);
>
> All these COM objects implement IDispatch and the information about
> their
> methods, method parameters, properties can be queried at runtime. So I
> was
> thinking maybe, there is a way to feed this information as metadata
> information to the script engine and this way I would be able to use
> the
> same syntax as in JScript What do you think, is it possible?
>
> Thanks
>
>
>
> "Volker Hilsheimer" <unwatched@xxxxxxx> wrote in message
> news:decmth$9v4$1@xxxxxxxxxxxxxxxxxxxxx
>> "B.C." <bikerc@xxxxxxxxx> wrote in message
>> news:ddedco$4p2$1@xxxxxxxxxxxxxxxxxxxxx
>>> Could you please tell me if it is possible to script activex objects
>>> in
>> the
>>> current version or in the next one?
>>>
>>> I am looking at whether it is possible to have code like the one
>>> below.
>> Or
>>> I should say more or less similar, but the bottom line is that the
>> activex
>>> object methods or properties should be specified using the syntax
>>> <objectName>.<propertyName> or <objectName>.<methodName>(<param1>,
>> <param2>)
>>> and not <objectName>.invoke("<methodName>", <param1>, <param2>):
>>>
>>> var ExcelSheet;
>>> ExcelApp = new ActiveXObject("Excel.Application");
>>> ExcelSheet = new ActiveXObject("Excel.Sheet");
>>> ExcelSheet.Application.Visible = true;
>>> ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
>>>
>>> I know that QSA is used to provide the means to easily script
>> applications
>>> using Qt, but in addition to this I need to be able to script
>>> activex
>>> objects, and the question is does QSA support it in the same way as
>> JScript
>>> does?
>>>
>>> If it doesn't, then I might as well use JScript and make activeX
>>> objects
>> out
>>> of my Qt script objects (crossplatform is not an issue for now).
>>
>> If you have your COM object wrapped in a QAxObject, then you should be
>> able to just add it to QSA and access the API through QSA.
>>
>> http://doc.trolltech.com/3.3/qaxobject.html
>>
>> Alternatively you can use the QAxScript* classes to have the Windows
>> Scripting Host automate your object.
>>
>> http://doc.trolltech.com/3.3/qaxscriptmanager.html
>>
>> Volker
>>
>>
Message 5 in thread
Joel you are right. I guess the question is if it is possible to add methods
and properties to an object dynamically at runtime as oposed to have them
defined as slots at compile time?
Maybe the Trolltech folks could point me to a source code file or a sample
that shows how to do it.
B.C.
"Joel Nordell" <joelnordell@xxxxxxxxx> wrote in message
news:15936b44336a41393c43fe3d3355e3c1@xxxxxxxxxxxx
> B.C.-
>
> Perhaps you can take advantage of QSA's ability to dynamically assign
> functions as members of objects:
>
> var myObj = new SomeKindOfObject; // Create an object
> myObj.myFunction = function(x) { myObj.call( "myFunction", x } //
> Create a dynamic function
> myObj.myFunction(4); // will actually do myObj.call("myFunction", 4);
>
> Maybe you could expand on that idea and write a function that inspects
> an ActiveX object and creates member functions like that?
>
> -Joel
>
>
>
> On Aug 24, 2005, at 8:58 AM, B.C. wrote:
>
> > Hi, Volker:
> >
> > Thank you for your answer. One more question. I looked at the spec for
> > qaxobject. While in JScript you can have:
> >
> > ExcelSheet = new ActiveXObject("Excel.Sheet");
> > ExcelSheet.Applicable.Visible=true
> >
> > in QSA you would write this (if you were to expose QAxObject api to
> > qsa):
> >
> > 1. ExcellSheet = new QAxObject(0, "Excel.Sheet");
> > 2. ExcelSheet.querySubObject("Applicable").dynamicCall( "Visible",
> > true);
> > (correct me if I am wrong here)
> >
> > I want to use the same syntax as in JScript for line 2. Is there a way
> > to do
> > this, and behind the scenes the QSA engine would invoke these calls,
> > that
> > is:
> > the statement ExcelSheet.Applicable.Visible=true gets translated
> > automatically by the engine in
> > ExcelSheet->querySubObject("Applicable")->dynamicCall( "Visible",
> > true);
> >
> > All these COM objects implement IDispatch and the information about
> > their
> > methods, method parameters, properties can be queried at runtime. So I
> > was
> > thinking maybe, there is a way to feed this information as metadata
> > information to the script engine and this way I would be able to use
> > the
> > same syntax as in JScript What do you think, is it possible?
> >
> > Thanks
> >
> >
> >
> > "Volker Hilsheimer" <unwatched@xxxxxxx> wrote in message
> > news:decmth$9v4$1@xxxxxxxxxxxxxxxxxxxxx
> >> "B.C." <bikerc@xxxxxxxxx> wrote in message
> >> news:ddedco$4p2$1@xxxxxxxxxxxxxxxxxxxxx
> >>> Could you please tell me if it is possible to script activex objects
> >>> in
> >> the
> >>> current version or in the next one?
> >>>
> >>> I am looking at whether it is possible to have code like the one
> >>> below.
> >> Or
> >>> I should say more or less similar, but the bottom line is that the
> >> activex
> >>> object methods or properties should be specified using the syntax
> >>> <objectName>.<propertyName> or <objectName>.<methodName>(<param1>,
> >> <param2>)
> >>> and not <objectName>.invoke("<methodName>", <param1>, <param2>):
> >>>
> >>> var ExcelSheet;
> >>> ExcelApp = new ActiveXObject("Excel.Application");
> >>> ExcelSheet = new ActiveXObject("Excel.Sheet");
> >>> ExcelSheet.Application.Visible = true;
> >>> ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
> >>>
> >>> I know that QSA is used to provide the means to easily script
> >> applications
> >>> using Qt, but in addition to this I need to be able to script
> >>> activex
> >>> objects, and the question is does QSA support it in the same way as
> >> JScript
> >>> does?
> >>>
> >>> If it doesn't, then I might as well use JScript and make activeX
> >>> objects
> >> out
> >>> of my Qt script objects (crossplatform is not an issue for now).
> >>
> >> If you have your COM object wrapped in a QAxObject, then you should be
> >> able to just add it to QSA and access the API through QSA.
> >>
> >> http://doc.trolltech.com/3.3/qaxobject.html
> >>
> >> Alternatively you can use the QAxScript* classes to have the Windows
> >> Scripting Host automate your object.
> >>
> >> http://doc.trolltech.com/3.3/qaxscriptmanager.html
> >>
> >> Volker
> >>
> >>