I and some colleagues are working in a university assignment which involves manipulating Windows Live Messenger messages. Since the official API doesn’t allow us to alter the messages we had to use Messenger Plus! Live. In the other hand the rest of our project was meant to be developed in .NET because we wanted to use web-services and other .NET features that can help us to do a decent project without too much trouble.
I will briefly try to explain to you how you can create a .NET class library and use it in a Messenger Plus! Plugin (which is written in Javascript).
First of all you have to create your class library in Visual Studio 2005.

Then write down your login into the new Class1.cs file (or Class1.vb, if you prefer programming in that awful language :-P) I have highlighted some elements that you must have. You will notice the declaration of an interface. Honestly, I haven’t tried this code without it, and in the place I learned how to do this they mentioned the need to have it.
using System;
using System.Collections;
using System.Text;
using System.Runtime.InteropServices;
using System.Collections.Generic;
namespace myFirstPlugin
public interface PluginInterface
string addToLog(string sender,string recipient,string message);
string getFullLog();
}
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Plugin
public class Message
string sender;
string recipient;
string message;
public Message(string sender, string recipient, string message)
this.sender = sender;
this.recipient = recipient;
this.message = message;
}
}
private List<Message> _log new List<Message>();
public string addToLog (string sender, string recipient, string message)
_log.Add(new Message(sender, recipient, message));
return sender + recipient + message;
}
public string getFullLog()
string log = “”;
foreach (Message msg in _log)
log += msg.sender + “>” + msg.recipient + “: “ + msg.message + “\r\n”;
return log;
}
}
}
All the extra code will be used to create an ActiveX control, which can be used in Javascript code in a HTML page or in this case in a Messenger Plus! plugin.
You can compile your class just to make sure it is ok, but to use it in your plugin the easy way is to compile it from Visual Studi 2005 Command Prompt. Run it with administrator privileges.

Change to your Class Library Project directory. You will have to create a Key.
> sn -k sgKey.snk
Compile your class signing your Assembly with a Strong Name. This way you will avoid some security warnings when you register your Assembly and use your ActiveX control.
> csc /t:library Plugin.cs /keyfile:sgkey.snk
This next step must be done in every computer where you install your plugin. In VS Command Prompt the executable is in PATH. In other computers, you can find it in \Windows\Microsoft.NET\Framework\v2.0.XXXXX\.
> regasm Plugin.dll /tlb:PluginNet.dll /codebase
(after this command you won’t be able to delete Plugin.dll. You must unregister the Assembly using: regasm /unregister Plugin.dll)
Ok. The .Net part is done! Now let’s do some Javascript.
When you reach this step you must install Messenger Plus! Live. Then create a new plugin like shown in the picture.

In the script window you can create an object of your class and use it as you want! In the middle of the code I have some comments that can help you to understand myFirstPlugin.
var myPlugin; //store object during chat session
var lastSent; //just a trick to prevent an outbound message from being seen as an inbound message. Kind of a Messenger Plus! bug…
function OnEvent_ChatWndCreated(ChatWnd)
//new chat window -> new plugin object
myPlugin= new ActiveXObject(“MyFirstPlugin.Plugin”);
}
function OnEvent_ChatWndDestroyed(ChatWnd)
//in the end print out the log
Debug.Trace(myPlugin.getFullLog());
}
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
//messageKind == 1 is a user message. Other values means nudges, winks, etc.
if(MessageKind==1 && lastSent!=Message){
//get your buddy e-mail. Assumes that you’re not in a group chat
var e = new Enumerator(ChatWnd.Contacts);
var email;
for(; !e.atEnd(); e.moveNext()) {
var Contact = e.item();
email= Contact.Email;
}
//log you message into the plugin
myPlugin.addToLog(Messenger.MyEmail,email,Message);
return Message;
}else{
lastSent=“”;
return Message;
}
}
//Same stuff as above
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
var e = new Enumerator(ChatWnd.Contacts);
var email;
for(; !e.atEnd(); e.moveNext()) {
var Contact = e.item();
email= Contact.Email;
}
myPlugin.addToLog(email,Messenger.MyEmail,Message);
lastSent=Message;
return Message;
}
In the end enable your plugin and pray that it works







