Just use the Win32 API GetForegroundWindow this will return the handle of the window then you can iterate through the current open chat windows to get the Plus! ChatWnd object.
code:
for ( var oChatWnd = new Enumerator( Messenger.CurrentChats ); !oChatWnd.atEnd(); oChatWnd.moveNext() ) {
if ( oChatWnd.item().Handle === Interop.Call( 'user32', 'GetForegroundWindow' ) {
return oChatWnd.item();
}
}