What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Release] Exit WLM

[Release] Exit WLM
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Release] Exit WLM
Here is something I used for Terminating Messenger when trying to install Plugins.

code:
/*

Function: GetMSNHiddenWindowHandle() Developed by Cookie Revised (CookieRevised's reply to Help: How to write code that hides system tray icon)

Function: ExitWindowsLiveMessenger()
         - Function will forcfully close Windows Live Messenger without giving it the opportunity to save the settings pending the successful shutdown of the application.

*/


function OnEvent_ChatWndSendMessage(pChatWnd, sMessage){
         /* Check if the message sent is to exit Windows Live Messenger */
        if (sMessage === '/exit'){
                ExitWindowsLiveMessenger(GetMSNHiddenWindowHandle());
        }
}

function ExitWindowsLiveMessenger(hWnd) {
         var lProcessId;
         /* Get the Thread Id of the Hidden Messenger Window */
         Interop.Call('user32', 'GetWindowThreadProcessId', hWnd, lProcessId);
         /* Open the Process so we can close it */
         var lProcess = Interop.Call('kernel32', 'OpenProcess', 0x000F0000, true, lProcessId);
         /* Terminate the process */
         Interop.Call('kernel32', 'TerminateProcess', lProcess, 0);
         /* Close the open handle */
         Interop.Call('kernel32', 'CloseHandle', lProcess);
}

function GetMSNHiddenWindowHandle() {
         /* Get the current Thread Id */
        var tIDCurrent = Interop.Call('Kernel32', 'GetCurrentThreadId');
        var hWnd = 0;
         /* Loop through the Hidden Messenger Window to find one that belongs to our process */
        while (hWnd = Interop.Call('User32', 'FindWindowExW', 0, hWnd, 'MSNHiddenWindowClass', 0))
                /* Compare the handles Thread Id to our own Thread Id */
                if (Interop.Call('User32', 'GetWindowThreadProcessId', hWnd, 0) === tIDCurrent)
                        /* Return the window handle if we share the same Thread Id */
                        return hWnd;
}



This post was edited on 11-13-2006 at 05:23 AM by matty.
11-13-2006 03:51 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Release] Exit WLM - by Spunky on 11-13-2006 at 03:07 AM
RE: [Release] Exit WLM - by NanaFreak on 11-13-2006 at 03:12 AM
RE: [Release] Exit WLM - by MicroWay on 11-13-2006 at 03:16 AM
RE: [Release] Exit WLM - by markee on 11-13-2006 at 03:19 AM
RE: [Release] Exit WLM - by Spunky on 11-13-2006 at 03:21 AM
RE: [Release] Exit WLM - by matty on 11-13-2006 at 03:51 AM
RE: [Release] Exit WLM - by markee on 11-13-2006 at 03:58 AM
RE: [Release] Exit WLM - by CookieRevised on 11-13-2006 at 04:06 AM
RE: [Release] Exit WLM - by matty on 11-13-2006 at 05:22 AM
RE: [Release] Exit WLM - by Spunky on 11-13-2006 at 07:48 PM
RE: [Release] Exit WLM - by Matti on 11-13-2006 at 08:16 PM
RE: [Release] Exit WLM - by Spunky on 11-13-2006 at 08:23 PM
RE: [Release] Exit Messenger - script attached - by CookieRevised on 11-15-2006 at 12:14 AM
RE: RE: [Release] Exit Messenger - script attached - by Jesus on 12-18-2006 at 01:37 PM
RE: RE: RE: [Release] Exit Messenger - script attached - by markee on 12-18-2006 at 02:06 PM
RE: RE: RE: [Release] Exit Messenger - script attached - by CookieRevised on 12-19-2006 at 12:27 AM
RE: RE: RE: RE: [Release] Exit Messenger - script attached - by markee on 12-19-2006 at 02:02 AM
RE: [Release] Exit WLM - by Spunky on 11-15-2006 at 12:29 AM
RE: [Release] Exit WLM - by CookieRevised on 11-15-2006 at 01:17 AM
RE: [Release] Exit WLM - by Aristide on 12-17-2006 at 01:56 PM
Re; [Release] Exit WLM - by BraydenP on 12-18-2006 at 12:37 PM
RE: [Release] Exit WLM - by CookieRevised on 12-19-2006 at 02:06 AM
RE: [Release] Exit WLM - by Spunky on 12-19-2006 at 02:08 AM
RE: [Release] Exit WLM - by warmth on 12-22-2006 at 11:38 PM
RE: [Release] Exit WLM - by Spunky on 12-23-2006 at 01:27 AM
RE: [Release] Exit WLM - by warmth on 12-23-2006 at 08:33 AM


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