What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Update number of contacts

Pages: (2): « First « 1 [ 2 ] Last »
Update number of contacts
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Update number of contacts
The .Count property when a window is created is properly incremented. When a window is closed the function is called before the .Count property is properly decremented so we need to -1.
10-22-2006 10:20 PM
Profile E-Mail PM Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Update number of contacts
Hi.
I really can't get i work! If I minus one I must open to window before it counts the windows, and if I don't minus one it allways says that there are one window open.
10-23-2006 01:11 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: Update number of contacts
You need to put the Messenger.CurrentChats.Count-1 in the OnEvent_ChatWndDestroyed event. If it only counts when you open a window, you're using the OnEvent_ChatWndDestroyed event which needs to remain as Messenger.CurrentChats.Count
<Eljay> "Problems encountered: shit blew up" :zippy:
10-23-2006 01:14 PM
Profile PM Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Update number of contacts
Hej.
I update the number of open windows with af function, wich means that it allways minus one.
This is my code (with danish comments):

code:
var Status = "fra";    // SÆTTER STATUS TIL/FRA
var oprindeligPB = Messenger.MyPersonalMessage; // GEMMER OPRINDELIGE PERSONLIGE BESKED

function OpdaterPB()
{
    if (Status == "til")
    {
        var online = 0;
        var offline = 0;
        var kontakter = Messenger.MyContacts;
        var e = new Enumerator(kontakter);
        for(; !e.atEnd(); e.moveNext()) {
            var kontakt = e.item();
            if(kontakt.Status == "1") {
            offline++;
            } else {
                online++;
            }
        }
        var alle = (online + offline);
        var igang = Messenger.CurrentChats.Count - 1;
        Messenger.MyPersonalMessage = "Online: " + online + " | Offline: " + offline + " | I alt: " + alle + " | Åbne vinduer: " + igang;
    }
}

// NÅR DU LOGGER PÅ : START
function OnEvent_Initialize(MessengerStart)
{   
    opdaterPB();
}
// NÅR DU LOGGER PÅ : SLUT

// NÅR DU LOGGER AF : START
function OnEvent_Uninitialize(MessengerExit)
{
    Messenger.MyPersonalMessage = oprindeligPB;
}
// NÅR DU LOGGER AF : SLUT

// NÅR EN KONTAKTER LOGGER PÅ : START
function OnEvent_ContactSignin()
{
    opdaterPB();
}
// NÅR EN KONTAKTER LOGGER PÅ : SLUT

// NÅR EN KONTAKTER LOGGER AF : START
function OnEvent_ContactSignout()
{
    opdaterPB();
}
// NÅR EN KONTAKTER LOGGER AF : SLUT

// NÅR ET VINDUE ÅBNES : START
function OnEvent_ChatWndCreated()
{
    OpdaterPB();
}
// NÅR ET VINDUE ÅBNES : SLUT

// NÅR ET VINDUE LUKKES : START
function OnEvent_ChatWndDestroyed()
{
    OpdaterPB();
}
// NÅR ET VINDUE LUKKES : SLUT

// LAVER MENU : START
function OnGetScriptMenu(Location)
{
    ScriptMenu = "<ScriptMenu>";
    ScriptMenu += "<MenuEntry Id=\"tilfra\">";
    if (Status == "fra")
    {
        ScriptMenu += "Slå til";
    } else {
        ScriptMenu += "Slå fra";
    }
    ScriptMenu += "</MenuEntry>";
    ScriptMenu += "</ScriptMenu>";
    return ScriptMenu;
}
// LAVER MENU : SLUT

// VALGT MENU : START
function OnEvent_MenuClicked(MenuItemId,Location,OriginWnd)
{
    switch(MenuItemId)
    {
        case "tilfra":
            if (Status == "fra")
            {
                Status = "til";
                MsgPlus.DisplayToast("Kontakt tæller", "Kontakt tæller er slået til.");
                opdaterPB();
            } else {
                Status = "fra";
                MsgPlus.DisplayToast("Kontakt tæller", "Kontakt tæller er slået fra.");
            }
            break;
    }
}
// VALGT MENU : SLUT

This post was edited on 10-23-2006 at 01:49 PM by SnuZZer.
10-23-2006 01:27 PM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


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