Shoutbox

Need help with ChatWnd::SendMessage - 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: Need help with ChatWnd::SendMessage (/showthread.php?tid=74082)

Need help with ChatWnd::SendMessage by Jacen on 05-01-2007 at 04:23 PM

Okay, I admit to being new with MSGPLus Live scripts and Jscript itself.

I'm trying to get my script to send a message in the current chat session. I'm looking at the ChatWnd::SendMessage page in the help guide thing but every code piece I try doesn't work, returning errors in the debug window. Can someone give me an example on how to properly do this? Thanks.


RE: Need help with ChatWnd::SendMessage by Felu on 05-01-2007 at 04:27 PM

What code are you using? We cannot help without that.


RE: Need help with ChatWnd::SendMessage by Jacen on 05-01-2007 at 04:29 PM

code:
function OnEvent_MenuClicked(sMenuId){
*snip*
    if(sMenuId=="mnuItem7"){
*snip*
    ChatWnd.SendMessage("Test");
    }
}


RE: Need help with ChatWnd::SendMessage by Felu on 05-01-2007 at 04:33 PM

Whats "*snip*"? Remove it! Also make sure ChatWnd is defined.


RE: Need help with ChatWnd::SendMessage by Huhu_Manix on 05-01-2007 at 04:35 PM

You must specify what is the ChatWnd like that :

code:
the_wnd=null;

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
  the_wnd = ChatWnd;
}

function OnEvent_MenuClicked(sMenuId){
    if(sMenuId=="mnuItem7"){
the_wnd.SendMessage("Test");
    }
}

Yes and like Felu said, what's "*snips*" ?
RE: Need help with ChatWnd::SendMessage by Paril on 05-01-2007 at 04:36 PM

He's trying to use ChatWnd when it's undefined from what I can see.

-Paril


RE: Need help with ChatWnd::SendMessage by Jacen on 05-01-2007 at 04:44 PM

*snips* is where I removed code from the posting that was unrelated to my request.

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
  the_wnd = ChatWnd;
}
Since you defined the_wnd here, does this mean my script can't create a conversation? (It must have recieved one message from my contact?)
RE: RE: Need help with ChatWnd::SendMessage by vikke on 05-01-2007 at 04:48 PM

quote:
Originally posted by Jacen
code:
function OnEvent_MenuClicked(sMenuId){
*snip*
    if(sMenuId=="mnuItem7"){
*snip*
    ChatWnd.SendMessage("Test");
    }
}



You will have to add all parameters for OnEvent_MenuClicked, not just sMenuId. There is one called OriginWnd, which is the ChatWnd object.
Code:
code:
function OnEvent_MenuClicked(sMenuId, Location, OriginWnd){
*snip*
    if(sMenuId=="mnuItem7"){
*snip*
        if(Location == 2){ // we are in chat window, not in contact list
    OriginWnd.SendMessage("Test");
        }

    }
}

Changes are made in bold.
RE: Need help with ChatWnd::SendMessage by Paril on 05-01-2007 at 04:49 PM

Is the function being called after you set the_wnd? If you tried clicking the menu beforehand it would just crash the script. I forget the function to get a chat window...

-Paril


RE: RE: Need help with ChatWnd::SendMessage by vikke on 05-01-2007 at 04:52 PM

quote:
Originally posted by Paril
Is the function being called after you set the_wnd? If you tried clicking the menu beforehand it would just crash the script. I forget the function to get a chat window...

-Paril

Use my code instead, it's how it should be. :-)
RE: Need help with ChatWnd::SendMessage by Jacen on 05-01-2007 at 04:58 PM

Thanks vikke, your code worked great :)


RE: Need help with ChatWnd::SendMessage by Paril on 05-01-2007 at 06:06 PM

Oh, sorry Vikke, you posted right before me and I didn't see it :p