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:
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. Update number of contacts
Hi.
I'm from Denmark and my english isn't good, but i'll try.
I have made a script (..or tried to make a script) which shows how many contacts there's online/offline, how many contacts there's on the list and how many windows there's open.
I have tried to make a timer which update the number in the personal message every second, but it doesn't works.

My script:

var Status = "fra";    // SÆTTER STATUS TIL/FRA
var oprindeligPB = Messenger.MyPersonalMessage;

function OpdaterPB()
{
    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;
    Messenger.MyPersonalMessage = "Online: " + online + " | Offline: " + offline + " | I alt: " + alle + " | Åbne vinduer: " + igang;
    AddTimer("1",100);
}

// NÅR DU LOGGER PÅ : START
function OnEvent_Initialize(MessengerStart)
{   
    if (Status == "til")
    {
        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()
{
    if (Status == "til")
    {
        opdaterPB();
    }
}
// NÅR EN KONTAKTER LOGGER PÅ : SLUT

// NÅR EN KONTAKTER LOGGER AF : START
function OnEvent_ContactSignout()
{
    if (Status == "til")
    {
        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

// TJEKKER TIMER : START
function OnEvent_Timer(id)
{
    if (id == "1")
    {
        opdaterPB();
    }
}
// TJEKKER TIMER : 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 information", "Kontakt information er slået til.");
                opdaterPB();
            } else {
                Status = "fra";
                MsgPlus.DisplayToast("Kontakt information", "Kontakt information er slået fra.");
                Messenger.MyPersonalMessage = oprindeligPB;
                CancelTimer(1);
            }
            break;
    }
}
// VALGT MENU : SLUT


Thanks in advance.
- Simon
10-22-2006 03:04 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Update number of contacts
CancelTimer(1); should be MsgPlus.CancelTimer("1");

Your timer interval is set for 100 which is 10 times a second. (I'm pretty sure that below minimum. Use 1000 instead.)

Thats all i noticed by having a quick look
<Eljay> "Problems encountered: shit blew up" :zippy:
10-22-2006 03:25 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
Hi.
It doesn't work.
The timer is only necessary beacuse the numbers of open chat windows is falling if you close the window with the button, and it doesn't fall if you close the window with "ESC".
10-22-2006 03:46 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Update number of contacts
As far as I can tell it should work. There is no point updating the PSM every second though as there is a limit to how often it updates (6 or times a minute I think :s) so any faster and nobody notices anyway.

My PSM+ script just uses the Messenger.CurrentChats.Count everytime a window is created or destroyed and it works fine
<Eljay> "Problems encountered: shit blew up" :zippy:
10-22-2006 03:50 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
Hi.
Ohh.. I'm confused. I'm also use Messenger.CurrentChats.Count, and actually it works when i press "ESC" (:-S) But when there aren't any windows open it still says that there is one open.
10-22-2006 03:56 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Update number of contacts
That's a problem I came across... it's wierd. Just use:
code:
--Messenger.CurrentChats.Count


Thats should take 1 away from the value. It makes it correct then all the time.
<Eljay> "Problems encountered: shit blew up" :zippy:
10-22-2006 05:33 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
Hi.
I'm sorry. I don't understand.

Like this?
code:
var igang = --Messenger.CurrentChats.Count;

Or like this?
code:
var igang = Messenger.CurrentChats.Count--;
10-22-2006 05:48 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Update number of contacts
should be the first one. If that method doesn't work, use:

code:
var igang = Messenger.CurrentChats.Count-1;


EDIT: [/code]

This post was edited on 10-22-2006 at 06:04 PM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
10-22-2006 06:03 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Update number of contacts
code:
var _enabled = new Boolean(false);
var oprindeligPB;

function _update_mypersonalmessage(_conversations) {
    var _online = 0;
    var _offline = 0;
    var _total = 0;
   
    for(var e = new Enumerator(Messenger.MyContacts); !e.atEnd(); e.moveNext()) {
       
        if(e.item().Status == 1) { _offline++; }
        else { _online++; }
    }
    var _total = (_online + _offline);
    Messenger.MyPersonalMessage = "Online: " + _online + " | Offline: " + _offline + " | I alt: " + _total + " | Åbne vinduer: " + _conversations;
}

function OnEvent_Initialize(bMessengerStart){
    try{
        oprindeligPB = Messenger.MyPersonalMessage;
    }catch (e){}
}

function OnEvent_SignInReady(sEmail) {
    if (oprindeligPB != Messenger.MyPersonalMessage){ oprindeligPB = Messenger.MyPersonalMessage; }
    if (_enabled == true) { _update_mypersonalmessage(Messenger.Chats.Count); }
}

function OnEvent_Uninitialize(bMessengerExit) {
    Messenger.MyPersonalMessage = oprindeligPB;
}

function OnEvent_ContactSignin(){
    if (_enabled == true) { _update_mypersonalmessage(Messenger.Chats.Count); }
}
function OnEvent_ContactSignout() {
    if (_enabled == true) { _update_mypersonalmessage(Messenger.Chats.Count); }
}

function OnEvent_ChatWndCreated(){
    if (_enabled == true) { _update_mypersonalmessage(Messenger.Chats.Count); }
}

function OnEvent_ChatWndDestroyed() {
    if (_enabled == true) { _update_mypersonalmessage(Messenger.Chats.Count-1); }
}

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;
}
function OnEvent_MenuClicked(MenuItemId,Location,OriginWnd) {
    switch(MenuItemId) {
        case "tilfra":
            if (_enabled == false) {
                _enabled = true;
                MsgPlus.DisplayToast("Kontakt information", "Kontakt information er slået til.");
                _update_mypersonalmessage(Messenger.Chats.Count);
            } else {
                _enabled = false;
                MsgPlus.DisplayToast("Kontakt information", "Kontakt information er slået fra.");
                Messenger.MyPersonalMessage = oprindeligPB;
            }
        break;
    }
}

Would look something like this.

This post was edited on 10-22-2006 at 06:35 PM by matty.
10-22-2006 06:34 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.
If i minus one (var igang = Messenger.CurrentChats.Count-1;) i must open to windows before the numbers of open chat windows change.
Hi again.
Maybe it is because i turn the counter on in a chatwindow and then it counts that window and don't want to minus it... In a way. :-P .. Does that sounds possible?
10-22-2006 07:04 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