Hi!
The function OnGetScriptMenu has a only Location Parameter...but, can i know the Chat Windows that open Menù if Menù isn't open by contact list?
I thought to find the handle of the active window and find the associated Chat Windows...but I don't know to do this
thank for all, bye!
Unfortunately, there isn't a way that I know of which allows you to get the ChatWnd where the menu is being opened. I think it's something Plus! is missing, or else it's because there's some kind of restriction...
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();
}
}
This post was edited on 07-08-2008 at 01:14 PM by matty.
Thank for replay!
But, if I use the function:
[code]for ( var oChatWnd = new Enumerator(Messenger.CurrentChats); !oChatWnd.atEnd(); oChatWnd.moveNext() ) {
if ( oChatWnd.Handle === Interop.Call('user32', 'GetForegroundWindow' )) {
Debug.Trace("ok")
return oChatWnd;
}
}
Ah, I see. Matty didn't test his code properly, and thus he mixed up a few things.
This should work fine:
code:function GetChatWnd() {
for ( var e = new Enumerator(Messenger.CurrentChats); !e.atEnd(); e.moveNext() ) {
var oChatWnd = e.item();
if ( oChatWnd.Handle === Interop.Call('user32', 'GetForegroundWindow' ) {
return oChatWnd;
}
}
return false;
}
And an implementation example:
code:function OnGetScriptMenu( nLocation ) {
if( nLocation === MENULOC_CHATWND ) {
var oChatWnd = GetChatWnd();
//Do anything you want with the ChatWnd object here...
//Maybe you need some error handling in case oChatWnd is false,
//when the foreground chat window couldn't be found.
} else {
//Contact list or mobile chat window
}
}
code:function chatAttuale(){
var Windows = Messenger.CurrentChats;
var e = new Enumerator(Windows);
for(; !e.atEnd(); e.moveNext())
{
var ChatWindow = e.item();
if ( ChatWindow.Handle == Interop.Call('user32', 'GetForegroundWindow' )) {
return ChatWindow
}
}
}