Shoutbox

account name in taskbar (msn polygamy) - 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: account name in taskbar (msn polygamy) (/showthread.php?tid=87509)

account name in taskbar (msn polygamy) by lespoils on 11-28-2008 at 08:31 PM

hi,

first of all i'm very new to the scripting and all.

my question is fairly simple. i'm presently using multiple accounts with messenger. and i have the following poblem.

when someone talks to either active accounts, the message flashes in the taskbar (as it normaly does, and that is fine). My problem is i wish i could know to whom (wich account active account) the message is meant before clicking on it.

so here's what i had in mind. Since the text u see in the taskbar seems to be the title of the chat window (hence the contact name) i was wondering if it is possible to add the msn name of the account.

so lets say my name is "lespoils" and my friend name is "crofteur", the flashing taskbar would show something like :
Lespoils : crofteur

so any information on how to do and where to start is very welcomed

Thx

Lespoils


RE: account name in taskbar (msn polygamy) by roflmao456 on 11-28-2008 at 10:32 PM

you can try out the "SetWindowText" user32 function.

JScript code:
Interop.Call("user32","SetWindowTextW",hWnd,"new window title");


example:
JScript code:
function OnEvent_ChatWndCreated(ChatWnd){
var contact;
for(e=new Enumerator(ChatWnd.Contacts);!e.atEnd();e.moveNext())contact=e.item();
Interop.Call("user32","SetWindowTextW",ChatWnd.handle,MsgPlus.RemoveFormatCodes(Messenger.MyName)+": "+MsgPlus.RemoveFormatCodes(contact.name));
}


RE: account name in taskbar (msn polygamy) by matty on 11-28-2008 at 11:32 PM

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


RE: account name in taskbar (msn polygamy) by lespoils on 12-01-2008 at 03:35 AM

hi again,

thx for the replies and information.

i tried pasting the  script you supplied but it doesnt seems to work. the exact error is:

Error: Expected ':' (code: -2146827285)
       File: test.js. Line: 29.

trying to understand what you did, maybe i'll manage to make it work sometime

thanks again
Lespoils


RE: account name in taskbar (msn polygamy) by lespoils on 12-01-2008 at 04:17 AM

where can i read about the setwindowtextW function ?


RE: account name in taskbar (msn polygamy) by matty on 12-01-2008 at 02:30 PM

quote:
Originally posted by lespoils
where can i read about the setwindowtextW function ?
SetWindowText Function()
quote:
Originally posted by lespoils
hi again,

thx for the replies and information.

i tried pasting the  script you supplied but it doesnt seems to work. the exact error is:

Error: Expected ':' (code: -2146827285)
       File: test.js. Line: 29.

trying to understand what you did, maybe i'll manage to make it work sometime

thanks again
Lespoils
Line 29:
code:
lpszNewTitle += MsgPlus.RemoveFormatCodes( oContact.item().Name ) + ( oContact.atEnd() ? '', ', ' );
Should be:
code:
lpszNewTitle += MsgPlus.RemoveFormatCodes( oContact.item().Name ) + ( oContact.atEnd() ? '' : ', ' );

RE: account name in taskbar (msn polygamy) by lespoils on 12-01-2008 at 07:48 PM

thx again matty,

will try that tonight, i do have a quick question for now,

why do u put a W at the end of the SetWindowsText function ?
is it something about Messenger Plus! script ?

Lespoils


RE: account name in taskbar (msn polygamy) by Spunky on 12-01-2008 at 07:54 PM

quote:
Originally posted by lespoils

why do u put a W at the end of the SetWindowsText function ?
is it something about Messenger Plus! script ?

Lespoils

It's because JScript is Unicode. The alternate version would be SetWindowTextA (I think it means ASCII). Although, I don't think you need to explicitly call those with the A at the end
RE: account name in taskbar (msn polygamy) by matty on 12-01-2008 at 08:28 PM

quote:
Originally posted by Spunky
quote:
Originally posted by lespoils

why do u put a W at the end of the SetWindowsText function ?
is it something about Messenger Plus! script ?

Lespoils

It's because JScript is Unicode. The alternate version would be SetWindowTextA (I think it means ASCII). Although, I don't think you need to explicitly call those with the A at the end
You certainly do need to. Otherwise the function will not know how to the parameters and how much memory to allocate to it.