Shoutbox

[OK]SendMessage Function - 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: [OK]SendMessage Function (/showthread.php?tid=91812)

[OK]SendMessage Function by Lén on 08-09-2009 at 10:12 PM

Hey it's me, again *-)

well, i would send a message in a window ... not that hard if i want to send it to the last personn who has talk to me, but ... if i want to choose another personn ?

I've found in the Help that i should use SendMessage:
http://msdn.microsoft.com/en-us/library/ms644950(VS.85).aspx

But how can i use it in the msg plus! Jscript ?

i've tried:

han = 2425418
SendMessage(han,"my string",0,0);


but t doesn't work .... i caught  the handle with:

var e = new Enumerator(Windows);
        for(; !e.atEnd(); e.moveNext())
        {
            var ChatWindow = e.item();
            Debug.Trace(" Handle: " + ChatWindow.Handle);
        }



Thanks !


RE: SendMessage Function by Spunky on 08-09-2009 at 11:00 PM

You want the ChatWindow object, not the handle. Then use it like

js code:
    ChatWindow.SendMessage("blah");

RE: SendMessage Function by Lén on 08-09-2009 at 11:26 PM

You didn't read my message !

If you have 3 chat windows opened, how do you know wich window it will be send ?

i can't use your code 'cause it send the msg to the "active" window ....


RE: SendMessage Function by Spunky on 08-09-2009 at 11:46 PM

I did read it but I assumed you would understand...


Use this to send to someone on your contact list...

js code:
for(var e = new Enumerator(Messenger.MyContacts); !e.atEnd(); e.moveNext()){
     if(e.item().Email == "Person you want to send message to"){
          e.item().SendMessage("blah");
          //e.item() = ChatWnd object
      }
}

Use this to send to someone who you have an open window with

js code:
for(var e = new Enumerator(ChatWnd.Contacts); !e.atEnd(); e.moveNext()){
     if(e.item().Email == "Person you want to send message to"){
          e.item().SendMessage("blah");
          //e.item() = ChatWnd object
      }
}

RE: SendMessage Function by Lén on 08-10-2009 at 02:23 AM

I Love You <3
Errrr...
Thanks A lot !!!!

EDIT:

I can't use the first cause i've never used Enumerator so ... where can I put SendMessage ? how ?
and the second, with opened windows ... tell me that ChatWnd is undefined (but i have 2 chats opened, and i'm online ... and for this one, i don't know either where and how to use SendMessage here.

Is that e.SendMessage ( errr no it doesn't work).

Sorry but i've started Javascript, Jscript and xml 3 days ago, i'm in love with ruby, it's lotta easier.


RE: SendMessage Function by Spunky on 08-10-2009 at 09:16 AM

Edited previous post. I made a  bit of a mistake...

It's:

code:
e.item().SendMessage("this is a message");

It is the e.item() you want, not e.SendMessage;

RE: SendMessage Function by Lén on 08-10-2009 at 12:02 PM

Yey but .... no :D

i've already tried, and i've just retried with your code,
the debug tell me that e.item doesn't use this property or method on

code:
e.item().SendMessage("blah");

RE: SendMessage Function by Mnjul on 08-10-2009 at 12:28 PM

Spunky and Lén: you can't apply SendMessage() to a Contact object. You need to chatWnd=Messenger.OpenChat(e.item()) and then chatWnd.SendMessage("the message").


RE: SendMessage Function by Spunky on 08-10-2009 at 12:53 PM

Ah, got confused with the original code... I knew it was the chatwnd object, but forgot that returned a contact...


RE: SendMessage Function by Lén on 08-10-2009 at 07:49 PM

thanks it finally works great !

if you have a bit of time, check my second post:
http://shoutbox.menthix.net/showthread.php?tid=91809