What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Need Help With Sending A Message

Need Help With Sending A Message
Author: Message:
flashmaniac
New Member
*


Posts: 2
Joined: Dec 2007
O.P. Huh?  Need Help With Sending A Message
Hello Everyone.
Im Having Trouble With This Function. :S


[boolean] SendMessage(
    [string] Message
);

I Dont Get How To Make It Send A Message, It Always Wants Me To Add Something In Or Take Something Out.
Someone Help Me!!!!!!! :o
12-23-2007 03:13 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: Need Help With Sending A Message
SendMessage is a child function of the ChatWnd object. Therefore, to use this function, you first need the object. There are plenty of functions which return a ChatWnd object instance, it's up to you in what situation you need to send the message!
  • You can send a message when a chat window is created by using the ChatWnd parameter of OnEvent_ChatWndCreated.
  • You can send a message when the user sends or receives a message by using the ChatWnd parameter of OnEvent_ChatWndSendMessage or OnEvent_ChatWndReceiveMessage.
  • You can send a message when the user clicks the Scripts button in a chat window and selects a menu-item from the script menu by using the OriginWnd parameter of OnEvent_MenuClicked.
  • You can send a message after you've opened a chat window with Messenger.OpenChat():
    code:
    var ChatWnd = Messenger.OpenChat("someone@hotmail.com");
    ChatWnd.SendMessage("Hello Someone!");
  • You can loop through the opened chat windows by enumerating the Messenger.CurrentChats collection and send messages.
  • ...
Or in other words: please be a bit more specific when you want your script to send a message. :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-23-2007 09:25 AM
Profile E-Mail PM Web Find Quote Report
flashmaniac
New Member
*


Posts: 2
Joined: Dec 2007
O.P. RE: Need Help With Sending A Message
Thanks!, Can You Give Some Examples Of The Ones Up Above?

These Ones:


You can send a message when a chat window is created by using the ChatWnd parameter of OnEvent_ChatWndCreated.

You can send a message when the user sends or receives a message by using the ChatWnd parameter of OnEvent_ChatWndSendMessage or OnEvent_ChatWndReceiveMessage.

You can send a message when the user clicks the Scripts button in a chat window and selects a menu-item from the script menu by using the OriginWnd parameter of OnEvent_MenuClicked.

Im A Begginner And Not Very Advanced So I Dont Really Know How These Functions Work.
12-24-2007 12:10 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: Need Help With Sending A Message
It's just a matter of finding a way to retrieve a ChatWnd object through one of the functions or events Plus! Live gives you. When you have a ChatWnd object, you'll have to check if you can send a message first with the ChatWnd.EditChangeAllowed property and then, you can send a message to it.

I'll give you one example about how you should find such things out.
quote:
Originally posted by flashmaniac
You can send a message when a chat window is created by using the ChatWnd parameter of OnEvent_ChatWndCreated.

  1. The scripting documentation is your best friend! Look up the event!
    quote:
    Scripting Documentation > Events > Messenger Events > OnEvent_ChatWndCreated

    The OnEvent_ChatWndCreated event is fired when a new chat window is created.

    Syntax
    code:
    OnEvent_ChatWndCreated(
        [object] ChatWnd
    );

  2. Now we know how our function declaration should be built. Plus! Live will try to find a function called OnEvent_ChatWndCreated in your script and when a chat window is created, it'll send a ChatWnd object as parameter to your function. Using this information, you can already built this event in your script:
    code:
    function OnEvent_ChatWndCreated(oChatWnd) {
       //oChatWnd will be a ChatWnd object for the chat window that was created
    }
  3. Because we want to send a message when the chat window is created, we'll need to know more about the ChatWnd.SendMessage() function. The scripting documentation says this:
    quote:
    Scripting Documentation > Objects > ChatWnd Object > SendMessage
    The ChatWnd::SendMessage function sends a message to the contacts currently present in the chat window.

    Syntax
    code:
    [boolean] SendMessage(
        [string] Message
    );
    Return Value
    If the message is sent successfully, the return value is true, else, the return value is false.
    ...
    Remarks
    ...
    The EditChangeAllowed property should be checked before this function is called.
  4. Now we know that the SendMessage function accepts one parameter Message of the type string, which means that it's a literal value. The return value of the function is a boolean value (true or false) defining if the function succeeded in sending the message or not. This value is important because you can't always be sure if the message was actually sent, since there are cases where Plus! can't send it. One of these cases is that the chat window was destroyed, but that would be very unlikely because in our case of OnEvent_ChatWndCreated, it was just created! However, in a serious script, you should take every possibility in account, but I won't go about that now. The other case is that the typing area is disabled because the contact has been blocked by the user. Therefore, the remarks state that you should first check if the ChatWnd.EditChangeAllowed property is set to true. Only then you know you can send a message. This brings us to the final piece of code:
    code:
    function OnEvent_ChatWndCreated(oChatWnd) {
       if(oChatWnd.EditChangeAllowed) { //Check if the typing area is available
          var Result = oChatWnd.SendMessage("Hello there!"); //Send the message
          Debug.Trace("SendMessage returned: "+Result); //Send the result to the script debugger, if you want to check if everything went right
       }
    }

And with this way too long manual, you should be able to find out the other things yourself! Because that's what scripting (and programming in general) is all about: combine the things you need in such a way that you can get the right result. ;)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-24-2007 10:55 AM
Profile E-Mail PM Web 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