What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Window Close after Signout

Window Close after Signout
Author: Message:
mickael9
Full Member
***


Posts: 117
Reputation: 3
32 / Male / Flag
Joined: Jul 2005
RE: RE: Window Close after Signout
quote:
Originally posted by absorbation
I suggest adding a timer to the script. Which the user can customise to what they want, e.g. make the window close after 10 seconds of the contact signing out. I personally would want it 10 minutes after a contact signed out. I often have tabs with tons of offline contacts who I stopped speaking to say, an hour ago :).

Adding a timer would make the script a lot better :P.

Done :D
code:
var Timers     = {};
var TimerCount = 0;

function OnEvent_ContactSignout(sEmail)
{
    CloseWindows();
}
function OnEvent_ChatWndContactRemoved(ChatWnd, sEmail)
{
    CloseWindows();
}
function OnEvent_Timer(sTimerId)
{
    if (sTimerId.substr(0, 13) == "AutoCloseWin_")
    {       
        try
        {
            Interop.Call("User32","SendMessageW", Timers[sTimerId].Wnd.Handle, 16, 0, 0);
        }
        catch (e){};
        delete(Timers[sTimerId]);
        TimerCount--;
    }
    else if (sTimerId.substr(0, 19) == "AutoCloseWinCancel_")
    {
        var oParams      = Timers[sTimerId];
        var sOldText     = oParams.EditText;
        var nOldSelStart = oParams.SelStart;
        var nOldSelEnd   = oParams.SelEnd;
        var Wnd          = oParams.Wnd;
       
        Wnd.EditText = sOldText;
        Wnd.EditText_SetCurSel(nOldSelStart, nOldSelEnd);
        MsgPlus.DisplayToast("","Canceled !");
       
        delete(Timers[sTimerId]);
        TimerCount--;
    }
}
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage)
{
    if (sMessage.substr(0,8) == "!cancel ")
    {
        var regex = /^!cancel ([0-9]+)/;
        var match = regex.exec(sMessage);
        if (!match)
            return sMessage;

        var sId = match[1];
        var sTimerId = "AutoCloseWin_" + sId;
       
        if (typeof(Timers[sTimerId]) != "undefined")
        {
            MsgPlus.CancelTimer(sTimerId);
            var Params = Timers[sTimerId];
            delete(Timers[sTimerId]);
           
            sTimerId = "AutoCloseWinCancel_" + sId;
            Timers[sTimerId] = Params;
            MsgPlus.AddTimer(sTimerId, 100);
            return '';
        }
    }
}
function CloseWindows()
{
    var chats = Messenger.CurrentChats;
    var e = new Enumerator(chats);

    for(; !e.atEnd(); e.moveNext())
    {
        var chat = e.item();
        var e2 = new Enumerator(chat.Contacts);
        var bCanClose = true;
        for (; !e2.atEnd(); e2.moveNext())
        {
            var contact = e2.item();
            bCanClose &= (contact.Status == 1);
        }
        if (bCanClose)
            CloseWindow(chat);
    }
}
function CloseWindow(oWnd)
{
    var nId      = (++TimerCount);
    var sTimerId = "AutoCloseWin_" + nId;
   
    var sText = "!cancel " + nId + " [This conversation will be closed in 10 seconds; send this text to cancel and restore the text typed here :)]";
   
    var nSelStart = oWnd.EditText_GetCurSelStart();
    var nSelEnd   = oWnd.EditText_GetCurSelEnd();
    var sOldText  = oWnd.EditText;
   
    var Params   = {"Wnd" : oWnd, "SelStart" : nSelStart, "SelEnd" : nSelEnd, "EditText" : oWnd.EditText};

    oWnd.EditText = sText;
    oWnd.EditText_SetCurSel(0, sText.length);
   
    Timers[sTimerId] = Params;
    MsgPlus.AddTimer(sTimerId, 10000);
}

.plsc File Attachment: Auto-close window.plsc (1.83 KB)
This file has been downloaded 107 time(s).

This post was edited on 08-21-2006 at 12:06 AM by mickael9.
08-20-2006 11:33 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Window Close after Signout - by Eagle_Erwin on 08-20-2006 at 09:07 PM
RE: Window Close after Signout - by Spunky on 08-20-2006 at 09:42 PM
RE: RE: Window Close after Signout - by Eagle_Erwin on 08-20-2006 at 10:00 PM
RE: Window Close after Signout - by artfuldodga on 08-20-2006 at 09:48 PM
RE: Window Close after Signout - by Spunky on 08-20-2006 at 09:50 PM
RE: Window Close after Signout - by Spunky on 08-20-2006 at 10:06 PM
RE: Window Close after Signout - by Eagle_Erwin on 08-20-2006 at 10:08 PM
RE: Window Close after Signout - by CookieRevised on 08-20-2006 at 10:20 PM
RE: RE: Window Close after Signout - by Eagle_Erwin on 08-20-2006 at 10:31 PM
RE: RE: RE: Window Close after Signout - by Jesus on 08-20-2006 at 11:19 PM
RE: Window Close after Signout - by mickael9 on 08-20-2006 at 10:22 PM
RE: Window Close after Signout - by Spunky on 08-20-2006 at 10:23 PM
RE: Window Close after Signout - by absorbation on 08-20-2006 at 10:28 PM
RE: Window Close after Signout - by CookieRevised on 08-20-2006 at 10:49 PM
RE: RE: Window Close after Signout - by mickael9 on 08-20-2006 at 11:33 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