What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » COM Events

COM Events
Author: Message:
omahena
New Member
*


Posts: 3
48 / Male / –
Joined: Jan 2007
O.P. Huh?  COM Events
Hi guys,

I have been looking for a way to register my script to handle events fired by a COM object.

In HTML JavaScript this is quite simple and there are many ways to do this. I expected that something like this would work:

code:
var SomeObject = new ActiveXObject("AppID.ClsID");
SomeObject.OnSomeEvent = EventHandlerFunc;

...

function EventHandlerFunc(EvtParam1)
{
}


but that doesn't work. I also tried using the GetRef function and some other methods. This article seemed to give some good pointers. Maybe this will inspire somebody.

http://msdn2.microsoft.com/en-us/library/ms974564.aspx

I think out of all the methods the ConnectObject() function seems the right way to go. I have a feeling that something similar is used for MsgPlus events due to the automagic-like function names. The bummer is that I cannot find a way to call this function.

Any ideas? :|
01-16-2007 09:30 PM
Profile PM Find Quote Report
omahena
New Member
*


Posts: 3
48 / Male / –
Joined: Jan 2007
O.P. RE: COM Events
OK... That was silly. (A) It seems that only this particular COM object misbehaved. COM Events can be handled as I expected:

code:
function OnEvent_Initialize(MessengerStart)
{
  var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  xmlHttp.onreadystatechange = ORSC;
  Debug.Trace("Init complete.");
}

function ORSC()
{
  Debug.Trace("onreadystatechange");
}

Thanks for reading. And thanks to CoolDuDe_i06 for inspiring me with the gmail script.
01-16-2007 10:19 PM
Profile PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: COM Events
That kind of event is scripted into the com object and isn't always the usable one. For standard events:

code:
var pActivex;
function OnEvent_Intialize(bMessengerStart){
pActivex = new ActiveXObject("MyProject.Control");
fnEventHandler();
}
var fnEventHandler = function(){
pActivex::MyEventName = function(){
// do my event stuff
}
}
or something along those lines. :P
01-16-2007 10:55 PM
Profile PM Find Quote Report
omahena
New Member
*


Posts: 3
48 / Male / –
Joined: Jan 2007
O.P. RE: COM Events
Thanks for your reply. I didn't even realize that what you wrote is valid JScript. :D

I always used the event handlers in this way:

code:
var pActivex;

function OnEvent_Intialize(bMessengerStart)
{
  pActivex = new ActiveXObject("MyProject.Control");
  pActivex.MyEventName = fnEventHandler;
}

function fnEventHandler()
{
  // do my event stuff
}

I think I must have neglected to implement some interface in my COM object that I tried to use from the script. I'll figure that out tomorrow. |-)

I'll verify everything and report back if it works.
01-16-2007 11:11 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On