Shoutbox

Block Un-Wished Logins - 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: Block Un-Wished Logins (/showthread.php?tid=87899)

Block Un-Wished Logins by shallow on 12-22-2008 at 12:44 PM

Hey guys!

Does anyb ody know, is it possible to block all un-wished logins? For Example I dont want to others to log in on my Msn, I would like to set the client to accept only my MSN adress to login.

(My brother has own computer, but he more likes to use my...  Is it possible to set the MSN, my adress can log in, but other adresses could not LOG IN?)

Thank you for responses!


RE: Block Un-Wished Logins by Matti on 12-22-2008 at 12:57 PM

Here's what you can do:

  1. Store your own email address in a global variable, for example:
    code:
    var sAllowedEmail = "myself@hotmail.com";
  2. In the OnEvent_Signin event, check the received first parameter (Email) against the allowed email address.
  3. If the email addresses match, do nothing.
  4. If the email addresses do not match, use Messenger.Signout() to make this unwanted user sign out. Display a friendly(?) toast message with MsgPlus.DisplayToast to inform them why he/she has just been signed out.
Although this will work great, it won't actually prevent them to sign in: they'll simply be signed out as soon as they are signed in, which is just as effective (and annoying) in my opinion. :P

Please, try not to ask us for copy-paste-ready code, this script request is very easy to achieve when you simply have a look at the scripting documentation. The best way to learn programming is by trying new things out yourself! ;)
RE: Block Un-Wished Logins by shallow on 12-22-2008 at 01:38 PM

Works perfectly ty ;)

You are right, I was thinkin, and was able to create it. Another question: Can you tell me the function name, which helps me to IGNORE if I want to add a new contact on my list? ( I don't want more contacts on my list, and I am afraid, My brother will add his friends to my contact list to be able communicate with them on my msn -.- xD)

He wont understand, why he wont be able to connect with his adress, but if he wont be able to add contact to my list too, he will give up the fight xD

Thanks Matti if you help me again x)


RE: Block Un-Wished Logins by Matti on 12-22-2008 at 07:27 PM

Unfortunately, there's no such functionality built into the Plus! Live scripting system yet. I don't know if it's possible through some kind of Messenger ActiveX function, although I'd really be surprised if a script could intercept a contact from being added. (The standard Messenger API isn't that great...)

Good to see you managed to get the code working and good luck fighting your brother! :P


RE: Block Un-Wished Logins by Pinecone on 12-23-2008 at 02:10 PM

You can however hook into messenger and stop them just clicking the add contact button or whatever. I almost got it working, but for some reason it freezes the messenger main window after. I sent it to a friend of mine for testing and he didn't have the problem, so I'm unsure if it will work correctly for everyone or not. The point is, it stops them from adding contacts by clicking the add contact button or going through the menu. If anyone could provide any information on why this is freezing up my messenger, please respond to this post as i spent over 4 hours trying to figure it out to no avail.

code:
var WH_CBT = 5;
var HCBT_CREATEWND = 3;
var hHook;

function OnEvent_Initialize(MessengerStart) {
    hHook = Interop.Call('User32.dll', 'SetWindowsHookExW',
        WH_CBT,
        Interop.GetCallbackPtr('CBTProc'),
        Interop.Call('Kernel32.dll', 'GetModuleHandleW', 'MsgPlusLive.dll'),
        Interop.Call('Kernel32.dll', 'GetCurrentThreadId')
    );
}

function OnEvent_Uninitialize(MessengerExit) {
    if (hHook) Interop.Call('User32.dll', 'UnhookWindowsHookEx', hHook);
}

function CBTProc(nCode, wParam, lParam) {
    // MSDN said to simply return CallNextHook with no further processing if nCode<0
    if (nCode >= 0)
    // Check for notification of a window being created
    if (nCode == HCBT_CREATEWND) {
       
        // Is the window in question the add contact window
        if (GetClass(wParam) == 'MSNContacts_Dialog') {
           
            // Show Error message
            Interop.Call('User32.dll', 'MessageBoxW', 0, 'Erorr: You are not allowed to add a contact.', 0, 0x10);
           
            // MSDN says that returning anything other than 0 will stop the window being created.
            return 1;
               
        }
        // MSDN says that returning 0 allows the window to be created.
        return 0;
    }
   
    // Call next hook...
    return Interop.Call('User32.dll', 'CallNextHookEx', hHook, nCode, wParam, lParam);
}

// Returns the class name of hWnd
function GetClass(hWnd) {
    var Data = Interop.Allocate(0x200);
    Interop.Call('User32.dll', 'GetClassNameW', hWnd, Data, 0x200);
    var Class = Data.ReadString(0);
    Data.Size = 0;
    return Class;
}


RE: RE: Block Un-Wished Logins by SmokingCookie on 12-28-2008 at 09:13 PM

quote:
Originally posted by Pinecone
You can however hook into messenger and stop them just clicking the add contact button or whatever

Or you could change your password 8-|
RE: Block Un-Wished Logins by Spunky on 12-28-2008 at 09:57 PM

quote:
Originally posted by shallow
You are right, I was thinkin, and was able to create it. Another question: Can you tell me the function name, which helps me to IGNORE if I want to add a new contact on my list? ( I don't want more contacts on my list, and I am afraid, My brother will add his friends to my contact list to be able communicate with them on my msn -.- xD)

You could also skin away the add contact button, but they would still be able to accept requests