Shoutbox

[help] Active ChatWnd - 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: [help] Active ChatWnd (/showthread.php?tid=71056)

[help] Active ChatWnd by LifelesS on 01-26-2007 at 02:26 PM

Hi, I'm building a script and on there's a point where you have a PlusWnd and when you click on a button it writes something on the ChatWnd. The problem is that I can't do it. :S

code:
function OnWndCharSelectEvent_CtrlClicked(PlusWnd, ControlId)
{
    switch(ControlId)
    {
        case "BtnClose":
            PlusWnd.Close(0);
            break;
           
        case "BtnInsert":
        var currenttext = ChatWindow.EditText;
        var SelectedChar = PlusWnd.Combo_GetCurSel("cbcChar");
        ChatWnd.EditText_ReplaceSel(SelectedChar);
        break;
    }
}[code]

I get "ChatWnd not defined" how can I define it? Can't find it.
[/code]
RE: [help] Active ChatWnd by Felu on 01-26-2007 at 02:38 PM

To get the handle of Active ChatWnd we can use FindWindowW

code:
ChatWnd = Interop.Call('User32',"FindWindowW",'IMWindowClass',0);


By this way you get the handle of the ChatWnd(ChatWnd.Hnadle) and not the chatwnd :P.
RE: [help] Active ChatWnd by Matti on 01-26-2007 at 02:39 PM

You don't have the ChatWnd declared. Can you tell us in which chat window the script should send the message?

For example, if the PlusWnd was created from a menu, you could create a global array and add an element with the PlusWnd's handle as key and the ChatWnd as handle, and look for that one when the event occurs.


RE: [help] Active ChatWnd by LifelesS on 01-26-2007 at 02:40 PM

Gonna try it Felu;

Mattike, it's in the active chat window


RE: [help] Active ChatWnd by Matti on 01-26-2007 at 02:47 PM

Well, the thing is that the chat window can't be on the foreground when you click your control in the PlusWnd. :-/


RE: [help] Active ChatWnd by LifelesS on 01-26-2007 at 02:49 PM

It doesn't work Felu, thanks for you help:)



Mattike, well, not all's possible in scripts, good thing is I can do it other way. Thanks:)


RE: [help] Active ChatWnd by Felu on 01-26-2007 at 02:51 PM

quote:
Originally posted by LifelesS
It doesn't work Felu, thanks for you help
I never said that it would return the object ChatWnd. It will return the handle of the last active chat wnd.
RE: [help] Active ChatWnd by CookieRevised on 01-26-2007 at 02:54 PM

I suggest to not do what Felu suggested, at first that is. As this will more than likely lead to errors and possible wrong windows (eg: take in account that there can be more than 1 chat window open, that the first found window is not the top-most chat window, that chat windows can even belong to other Messenger sessions (polygamy), etc etc))

Do as Mattike suggested and add a logical way to retrieve in what chat window you want to write something (by the use of a global variable for example like he suggested).

If this isn't possible at all, then you could do a manual search for chat windows. But use the chatwnds enumeration object and not the findwindow api!!!. And in each enumeration you check the Z-order of the window handle with a windows API, the lowest one (aka the top-most), or was it the biggest one.. dunno anymore :p, is the one you need.

PS: And do not forget to check if you actually can edit/write something to the chat window before you actually write or manipulate the cursor!


RE: [help] Active ChatWnd by LifelesS on 01-26-2007 at 02:58 PM

I'm using other way, I'm going to replace the text you write instead of having to press a button to write the text.


RE: RE: [help] Active ChatWnd by vikke on 01-26-2007 at 03:30 PM

quote:
Originally posted by Felu
To get the handle of Active ChatWnd we can use FindWindowW
code:
ChatWnd = Interop.Call('User32',"FindWindowW",'IMWindowClass',0);


By this way you get the handle of the ChatWnd(ChatWnd.Hnadle) and not the chatwnd :P.

It should not work with tabs, as MessengerPlus! creates another window class for tabbed chats. GetForgroundWindow API might work :)