Shoutbox

New Messages Popup - 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: New Messages Popup (/showthread.php?tid=72938)

New Messages Popup by ArkaneArkade on 03-23-2007 at 11:48 PM

Hey All,
sorry to ask for help so soon again but my script ran into a small brick wall.  I'm looking for how to call an event only on first  contact.

I'm not explaining it very well.  Basically I mean that when you recieve a message for the first time, WLM creates a popup telling you the contacts, and their message.  I'm looking to call a function when this happens, but not when subsequent messages are recieved, unless the window has been closed again.

is there any Event Handler or way to do this?

Cheers guys


RE: New Messages Popup by Jesus on 03-24-2007 at 12:25 PM

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.
RE: New Messages Popup by ArkaneArkade on 03-25-2007 at 04:38 PM

I'll give it a try, thanks mate.