What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » account name in taskbar (msn polygamy)

account name in taskbar (msn polygamy)
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: account name in taskbar (msn polygamy)
I think something like this would work. I am at work and cannot test it but this is what it does

It will change the title of the window if it isn't in the foreground and restores it when the window is brought forward. There is already a glitch I can tell of without even running it and that would be if the contact changes their name then the script wont update it and the new title will be visible. But this is something that could be worked upon.

jscript code:
var oChatWnds = { };
var oChatWnds_WinTitle = { };

function OnEvent_ChatWndSendMessage( pChatWnd, sMessage ) {
    oChatWnds[ pChatWnd.Handle ] = sMessage;
}

function OnEvent_ChatWndDestroyed( pChatWnd ) {
    delete oChatWnds[ pChatWnd.Handle ];
    delete oChatWnds_WinTitle[ pChatWnd.Handle ];
}

function OnEvent_ChatWndReceiveMessage( pChatWnd, sOrigin, sMessage, nMessageKind ) {
    // check if the event is thrown because our message was recieved in the chat history
    if ( oChatWnds[pChatWnd.Handle] !== sMessage ) {
        // check if the current window isn't the chat window
        if ( Interop.Call( 'user32', 'GetForegoundWindow' ) !== pChatWnd.Handle ) {
            // get the current title to restore once the window has been brought forward
            var intTitleLength = Interop.Call( 'user32', 'GetWindowTextLengthW', pChatWnd.Handle );
            var lpszTitle = Interop.Allocate( intTitleLength );
            Interop.Call( 'user32', 'GetWindowTitleW', pChatWnd.Handle, lpszTitle, intTitleLength );
            oChatWnds_WinTitle[ pChatWnd.Handle ] = lpszTitle.ReadString( 0 );
           
            // create a string to hold the new title
            var lpszNewTitle = MsgPlus.RemoveFormatCodes( Messenger.MyName )+' : ';
            // loop through all of the contacts
            for( var oContact = new Enumerator( pChatWnd.Contacts ); !oContact.atEnd(); oContact.moveNext() ) {
                // concatenate a string for all participants
                lpszNewTitle += MsgPlus.RemoveFormatCodes( oContact.item().Name ) + ( oContact.atEnd() ? '', ', ' );
            }
           
            // set the new title for the window
            Interop.Call( 'user32', 'SetWindowTextW', pChatWnd.Handle, lpszNewTitle );
           
            // use a timer to verify when the window is brought to the front
            MsgPlus.AddTimer( pChatWnd.Handle, 100 );
        }
    }
}

function OnEvent_Timer( sTimerId ) {
    // check if the window is the front window
    if ( Interop.Call( 'user32', 'GetForegroundWindow' ) !== sTimerId ) {
        // since the window is still in the background lets make sure it still exists before readding the timer for it
        if ( Interop.Call( 'user32', 'IsWindow', sTimerId ) ) MsgPlus.AddTimer( sTimerId, 100 );
       
        // exit the function
        return;
    }
   
    // set the old window title now that the window is brought forward
    Interop.Call( 'user32', 'SetWindowTextW', sTimerId, oChatWnds_WinTitle[ sTimerId ] );   
}

This post was edited on 11-28-2008 at 11:34 PM by matty.
11-28-2008 11:32 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
account name in taskbar (msn polygamy) - by lespoils on 11-28-2008 at 08:31 PM
RE: account name in taskbar (msn polygamy) - by roflmao456 on 11-28-2008 at 10:32 PM
RE: account name in taskbar (msn polygamy) - by matty on 11-28-2008 at 11:32 PM
RE: account name in taskbar (msn polygamy) - by lespoils on 12-01-2008 at 03:35 AM
RE: account name in taskbar (msn polygamy) - by lespoils on 12-01-2008 at 04:17 AM
RE: account name in taskbar (msn polygamy) - by matty on 12-01-2008 at 02:30 PM
RE: account name in taskbar (msn polygamy) - by lespoils on 12-01-2008 at 07:48 PM
RE: account name in taskbar (msn polygamy) - by Spunky on 12-01-2008 at 07:54 PM
RE: account name in taskbar (msn polygamy) - by matty on 12-01-2008 at 08:28 PM


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