Shoutbox

Sleeping - 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: Sleeping (/showthread.php?tid=85785)

Sleeping by Zero on 09-05-2008 at 04:29 PM

Hi folks - i'm just wondering how i'd go about sleeping my script? Actually, it may not be necessary since what I'm trying to do is figure out an easy way to refer back to a specific chat window after a given time interval. I don't wanna throw the chtwnd object into a global since it could get over-written; I can't pass the handle as a user-data param to AddTimer; and I can't seem to get seem to get the Sleep method of the WScript object to work (not too surprising I guess). Any other ideas?

  Zero


RE: Sleeping by matty on 09-05-2008 at 05:23 PM

Global Variable:

code:
var oChatWnds = {};

Object assignment:
code:
oChatWnds[oChatWnd.Handle] = oChatWnd

This will never be overwritten however on the closing of a chat window you will want to do the following:

code:
delete oChatWnds[oChatWnd.Handle];

RE: Sleeping by Zero on 09-05-2008 at 10:37 PM

I don't see how that'd work tho since I don't have access to the chat window handle as a param in the timer event func... while i'm waiting for the timer to fire, it'll be possible for the handle in the global to be overwritten...


RE: Sleeping by pollolibredegrasa on 09-05-2008 at 11:15 PM

Why not make the TimerId the chat window handle in your AddTimer call?

code:
MsgPlus.AddTimer(oChatWnd.Handle,5000);
Then in your timer event you could just enumerate the opened chat windows to find the one which has a handle that matches the TimerID:
code:
function OnEvent_Timer(sTimerId){
    var e = new Enumerator(Messenger.CurrentChats);
    for(; !e.atEnd(); e.moveNext()){
        var ChatWindow = e.item();
        if (ChatWindow.Handle == sTimerId){
            //Do whatever here
        }
    }
}

Something like that should work...
RE: Sleeping by matty on 09-07-2008 at 05:29 AM

quote:
Originally posted by pollolibredegrasa
code:
function OnEvent_Timer(sTimerId){
    var e = new Enumerator(Messenger.CurrentChats);
    for(; !e.atEnd(); e.moveNext()){
        var ChatWindow = e.item();
        if (ChatWindow.Handle == sTimerId){
            //Do whatever here
        }
    }
}


You don't even need to do that... if you do what I said and what you said about using the timer as a param you can simply do the following:
code:
function OnEvent_Timer(sTimerId) {
    Debug.Trace(oChatWnds[paraseInt(sTimerId)].Handle);
}

RE: Sleeping by Zero on 09-08-2008 at 03:38 PM

Brilliant! Thanks, guys!