What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » function OnGetScriptMenu - ChatWnd

function OnGetScriptMenu - ChatWnd
Author: Message:
Suxsem
Junior Member
**


Posts: 66
Joined: Mar 2008
O.P. function OnGetScriptMenu - ChatWnd
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 :D
thank for all, bye!
07-07-2008 12:12 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: function OnGetScriptMenu - ChatWnd
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...

Someone ask Patchou about this? :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
07-07-2008 12:17 PM
Profile E-Mail PM Web Find Quote Report
Suxsem
Junior Member
**


Posts: 66
Joined: Mar 2008
O.P. RE: function OnGetScriptMenu - ChatWnd
ok...thank
07-07-2008 12:20 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: function OnGetScriptMenu - ChatWnd
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.
07-07-2008 04:08 PM
Profile E-Mail PM Find Quote Report
Suxsem
Junior Member
**


Posts: 66
Joined: Mar 2008
O.P. RE: function OnGetScriptMenu - ChatWnd
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;
    }
}

"ok" never display in debug windows!
07-08-2008 11:09 AM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: function OnGetScriptMenu - ChatWnd
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
    }
}
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
07-08-2008 11:39 AM
Profile E-Mail PM Web Find Quote Report
Suxsem
Junior Member
**


Posts: 66
Joined: Mar 2008
O.P. RE: function OnGetScriptMenu - ChatWnd
ok...this function is correct:
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
     }
}
}
thank for all, bye!
07-08-2008 11:41 AM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: function OnGetScriptMenu - ChatWnd
quote:
Originally posted by Mattike
Ah, I see. Matty didn't test his code properly, and thus he mixed up a few things. :)

code:
var oChatWnd = e.item();

Oops haha

Updated the previous post... thanks Matti it has been awhile since I have written Plus! Scripts... I should get back to it...

This post was edited on 07-08-2008 at 01:17 PM by matty.
07-08-2008 01:13 PM
Profile E-Mail PM Find Quote Report
« 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