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

Pages: (3): « First [ 1 ] 2 3 » Last »
[Release] Exit WLM
Author: Message:
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
O.P. [Release] Exit WLM
Haven't really worked on this too much, but I found it useful (both for a practical use and for teaching myself some new practices).

You basically just type /exitwlm <seconds> and it will signout at that time.
There is a warning at 5 seconds which also allows the user to cancel the countdown. I set a limit of at least 10 seconds as there is no point in having it any sooner than that.

If no-one finds it useful, new scripters can still learn things from it...

.plsc File Attachment: Exit WLM.plsc (1.24 KB)
This file has been downloaded 521 time(s).
<Eljay> "Problems encountered: shit blew up" :zippy:
11-13-2006 03:07 AM
Profile PM Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: [Release] Exit WLM
that is cool Spunky.... i havent used yet but i am going to look at the code to see how you did it :P

nice

edit: i thought that it closed and exited WLM not sign out... you can do this by typing /signout :P

This post was edited on 11-13-2006 at 03:15 AM by NanaFreak.
11-13-2006 03:12 AM
Profile PM Find Quote Report
MicroWay
Senior Member
****

Avatar
Do you want me? Try to get me!

Posts: 571
Reputation: 16
37 / Male / Flag
Joined: Jul 2006
Status: Away
RE: [Release] Exit WLM
For my "very powerfull" skils on coding, I'll use your Script for learning purpose :P
Thanks
;)
11-13-2006 03:16 AM
Profile PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1622
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: [Release] Exit WLM
I was hoping this was actually going to exit out of messenger completely :sad:

Anyway, it looks quite good, I think with a little bit of adjustment the script should also be able to sign someone out of WLM at a particular time of the day as like a reminder to go to bed or something like that.  Also it could be useful for parents or bosses to stop people from using WLM all day if they wished, especially if a kind of cool down ferature was in place to stop someone signing back in for a set period of time after the script has signed you out, or possibly between set periods of time.  And if you really wanted to expand on it further you could also make the time periods user dependant too.

Anyway good job on the script, I hope you like my ideas to help you develop the script further.

EDIT:
quote:
Originally posted by NanaFreak
edit: i thought that it closed and exited WLM not sign out... you can do this by typing /signout
You might be able to do that but this script has a timer in it so you can set it to sign you out in like 30sec or something.

This post was edited on 11-13-2006 at 03:22 AM by markee.
[Image: markee.png]
11-13-2006 03:19 AM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
O.P. RE: [Release] Exit WLM
I had some of those ideas myself, but didn't know if the idea was going to be "popular" lol. I might develop it then to have more features such as parental controls etc ;)

EDIT: As for exiting WLM completely, I think it's possible if I can find a way to close processes (or include an exe that can do it and open it from the script)

This post was edited on 11-13-2006 at 03:23 AM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
11-13-2006 03:21 AM
Profile PM Find Quote Report
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
markee
Veteran Member
*****

Avatar

Posts: 1622
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: [Release] Exit WLM
* markee <3 Matty

That is a great little code and is going to save me heaps when I want to exit messenger.  Thanks heaps.
[Image: markee.png]
11-13-2006 03:58 AM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [Release] Exit WLM
quote:
Originally posted by SpunkyLoveMuff
EDIT: As for exiting WLM completely, I think it's possible if I can find a way to close processes (or include an exe that can do it and open it from the script)
warning: don't attempt that if you don't know how... closing messenger in that way will brute force close it and things will not be saved properly. Many errors, including crashes and data loss can happen...

Scripts are run from inside Plus!, which on its turn is run from inside Messenger. Closing Messenger that way will forcefully break down that whole pyramid instead of nicely exiting step by step.

eg: Plus! needs time to wraps things up, Messenger needs time to wrap things up, etc...

---------------

Matty, if you do use such a code for a forceable close, use the ExitProcess API instead of the TerminateProcess API. See MSDN why.... Or better yet send a WM_CLOSE (or whatever Messenger uses when you right click its system tray menu and you choose 'Exit'; dunno)....

I'm even not sure if the handle gets closed. It might be possible that this is done automatically, but I'm certainly not certain. You would need to check what will happen with a handle created from within the process you are closing in the Windows API docs or even by monitoring the Windows handles for a possible handle leakage.

I'm not convinced that that code is safe.

This post was edited on 11-13-2006 at 04:18 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
11-13-2006 04:06 AM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Release] Exit WLM
quote:
Originally posted by CookieRevised
Matty, if you do use such a code for a forceable close, use the ExitProcess API instead of the TerminateProcess API. See MSDN why.... Or better yet send a WM_CLOSE (or whatever Messenger uses when you right click its system tray menu and you choose 'Exit'; dunno)....

Fixed as per Cook's instructions.

code:
/*

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();
        }
}

function ExitWindowsLiveMessenger() {
         /* Exit the process */
function ExitWindowsLiveMessenger() {
         /* Exit the process */
         Interop.Call('kernel32',
                      'ExitProcess',
                      Interop.Call('kernel32',
                                   'GetExitCodeProcess',
                                   Interop.Call('kernel32',
                                                'GetCurrentThreadId'),
                                   0)
                      );
}


This post was edited on 11-13-2006 at 04:01 PM by matty.
11-13-2006 05:22 AM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
O.P. RE: [Release] Exit WLM
That code just causes WLM to crash =/
<Eljay> "Problems encountered: shit blew up" :zippy:
11-13-2006 07:48 PM
Profile PM Find Quote Report
Pages: (3): « First [ 1 ] 2 3 » 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