Shoutbox

help block system - 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: help block system (/showthread.php?tid=66810)

help block system by tyron on 09-30-2006 at 02:28 PM

I'm trying to create a script that auto-blocks and specified user when I sign out and automatically unblocks it when I sign in...
I think it's useful if you have a person that you should only talk from one place (like work) and don't want to be bored at your home, for example..

The problem is that I'm having problems trying to auto-block when I sign out - the function OnEvent_Signout is executed AFTER the WLM is closed, so the function to block is not well executed...

That's what I made this far (as I'm brazilian, I might have forgotten to translate some variable... Although, I don't think it'd be a problem):

code:
var BlockedUser = "___@hotmail.com"; //here comes the target email
var meuEmail = "_______@hotmail.com"; //here comes mine email

function OnEvent_Initialize(MessengerStart)
{
Debug.Trace("Hello World!");
}

function OnEvent_Uninitialize(MessengerExit)
{
}


function OnEvent_MyStatusChange(NewStatus) {
    if(Messenger.MyEmail == meuEmail)
        {
            Contact = Messenger.MyContacts.GetContact(BlockedUser);
       
            if (NewStatus!=2) {
            Contact.Blocked = true;
            } else
            Contact.Blocked = false;
        }
}


function block(contato,status)
{
    if(status== "no")
    {
        contato.Blocked = false;
    } else {
        contato.Blocked = true;
    }
}

function OnEvent_SigninReady(Email)
{
    if(Messenger.MyEmail == meuEmail)
        {
            Contact = Messenger.MyContacts.GetContact(BlockedUser);
   
            block(Contact,"no");
        }

}


function OnEvent_Signout(Email)
{
    if(Messenger.MyEmail == meuEmail)
        {
            try
                {
                    Contact = Messenger.MyContacts.GetContact(BlockedUser);
                    block(Contact,"yes");
                }
            catch(err)
                {
                    Debug.Trace(" Error");
                }

        }
}



Thank you a lot
RE: help block system by Spunky on 09-30-2006 at 02:48 PM

Could you not just use OnEvent_Uninitialize for it? It's called when the script is ending though, not the program.


RE: help block system by tyron on 09-30-2006 at 03:18 PM

quote:
Originally posted by SpunkyLoveMuff
Could you not just use OnEvent_Uninitialize for it? It's called when the script is ending though, not the program.

Hi,
I tried it too... But it still don't execute the final function..
I don't know if you understood me clearly: the function to block the contact should be called when the program is closing, like right-clicking on the icon next to the clock and choosing "Exit"...

Thanks again
RE: help block system by Spunky on 09-30-2006 at 03:29 PM

OnEvent_Uninitialize always works for me... Have you checked the debug window for any errors? (I know that seems like a stupiod thing to say, but you'd be surprised)



RE: help block system by tyron on 09-30-2006 at 03:59 PM

I checked the debug yes and I can quickly see that there's an error, but as I'm making changes to the closing of the program, the window closes itself before I can see exactly what it's written.

In fact, I think I know which error is being displayed: probably it's WLM telling me that the contact could not be blocked, as the connection (and the contact list) has already been closed.

Do you have any ideia?
Thks


RE: help block system by Spunky on 09-30-2006 at 04:01 PM

I haven't, but I bet there are people that can sort out (easily) for you. I don't have too mcuh experience with running functions as the program is closing down, just setting a few variables in the registry.


RE: help block system by tyron on 09-30-2006 at 04:06 PM

Ok so.. I'll wait for any other help...
But thank you very much for this help..


RE: help block system by tyron on 10-03-2006 at 10:47 PM

nobody knows???


RE: help block system by deAd on 10-03-2006 at 11:16 PM

Please don't bump threads.

As far as I know, you can not do an action that requires you to be signed in when the user signs out. The events only tell you when it's too late.