Shoutbox

Get Contacts in a chat - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Get Contacts in a chat (/showthread.php?tid=83738)

Get Contacts in a chat by Scripty on 05-15-2008 at 06:39 PM

Hi
I am trying to get the name of a contact who I am trying to start a conversation with or who is trying to start a new conversation with me. So I added code to the function OnEvent_ChatWndCreated(ChatWnd) event
I am new to scripting so can anyone please provide me with a code snippet. I have written this

function OnEvent_ChatWndCreated(ChatWnd)
{
    m = ChatWnd.Contacts[1];
    alert(m.Name);
   
}

but it says

Script is starting
Script is now loaded and ready
Function called: OnEvent_Initialize
Function called: OnEvent_ChatWndCreated
Error: 'm.Name' is null or not an object (code: -2146823281)
       File: warn.js. Line: 13.
Function OnEvent_ChatWndCreated returned an error. Code: -2147352567

Thanks


RE: Get Contacts in a chat by roflmao456 on 05-15-2008 at 07:33 PM

well you need to set up an Enumerator and iterate through the contact objects

code:
function OnEvent_ChatWndCreated(ChatWnd){
for(var e = new Enumerator(ChatWnd.Contacts);!e.atEnd();e.moveNext()){
    Debug.Trace(e.item().Name);
    }
}

that will list all the names of the contacts in the conversation window (prints to the debugging window btw)


edit: if you look in the Scripting Documentation there is an example that is similar to this, except it lists the emails of the whole contact list. (uses same method)
RE: Get Contacts in a chat by Scripty on 05-15-2008 at 07:50 PM

Thank :)