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

New Messages Popup
Author: Message:
Jesus
Scripting Contest Winner
****

Avatar
Koffie, my cat ;)

Posts: 623
Reputation: 15
38 / Male / Flag
Joined: Jul 2005
RE: New Messages Popup
I'm not sure whether you want to call your function only if the contact initiates the chat or also when you start a convo and your contact responds for the first time.
My most logical guess is the first (contact initiates chat), so i wrote a bit of code for that:
code:
var aNewChat = new Array();
var aSent = new Array();

function OnEvent_ChatWndCreated(oChatWnd)
{
    aNewChat[oChatWnd.Handle] = 1;    //mark the convo as a new one
    MsgPlus.AddTimer("NewChat" + oChatWnd.Handle, 100);  //set a timer to remove "new" mark
}

function OnEvent_Timer(sTimerId)
{
    if (sTimerId.substr(0, 7) == "NewChat")
    {
        delete aNewChat[sTimerId.substr(7)];  //remove "new" mark
    }
}

function OnEvent_ChatWndSendMessage(oChatWnd, sMessage)
{
    aSent[oChatWnd.Handle] = sMessage;  //store last sent message for the chat window
}

function OnEvent_ChatWndReceiveMessage(oChatWnd, sOrigin, sMessage, eMessageKind)
{
    if (sMessage == aSent[oChatWnd.Handle])  //check if you sent the message yourself
    {
        delete aSent[oChatWnd.Handle];  //if it was your message, delete it from the array
    } else {
        if (aNewChat[oChatWnd.Handle] == 1)  //check if it's a "new" convo
        {
            //do your stuff here
        }
    }
}
This code will do your stuff there if a contact sends a message which opens a chat on your side, or in the quite unlikely scenario where a contact sends you a message within 100ms after you opened a convo with them.

This post was edited on 03-24-2007 at 12:26 PM by Jesus.
Man is least himself when he is in his own person. Give him a mask and he will tell you the truth. (Oscar Wilde)
03-24-2007 12:25 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
New Messages Popup - by ArkaneArkade on 03-23-2007 at 11:48 PM
RE: New Messages Popup - by Jesus on 03-24-2007 at 12:25 PM
RE: New Messages Popup - by ArkaneArkade on 03-25-2007 at 04:38 PM


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