Shoutbox

send message withouth knowing windowhandle? - 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: send message withouth knowing windowhandle? (/showthread.php?tid=76260)

send message withouth knowing windowhandle? by runarius on 07-23-2007 at 01:01 AM

Hi, I am a script developer for the salling clicker(software for using any bluetooth phone as a remotecontrol for the computer) and right now, I am creating a script for using msn on your phone, through salling clicker.

I was just wondering if it is possible to send a message from the msn-plus-script to a contact with just knowing his e-mail adress? I know it is possible with the window-handle but I don't want to use that approach.

Also, is it possible to export all of my online contact and their status to a textfile?


RE: send message withouth knowing windowhandle? by Deco on 07-23-2007 at 01:24 AM

Well to send message to a contact knowing his email...

1) Iterate the contact list object
2) Match the email you want with the contact's object
3) Use the OpenChat function sending the contact you found
4) Check if the chat window was opened
5) Send your message with the SendMessage function.

code:
var strEmail = "email@email.com";
var strMsg = "msg you want to send";
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext())
{
    var Contact = e.item();
                if (Contact.Email == strEmail) {
                    var ChatWnd = Messenger.OpenChat(Contact);
                    if(ChatWnd != "null") {
                       ChatWnd.SendMessage(strMsg);
                    } else {
                        //actions in case it could not open the chat
                    }
}

}


I wrote this from the top of my head so I might have missed something. I'm sure someone will correct me if I'm wrong or if there's a better method. Didn't test the code. But I'm sure this will give you a clue on which direction to go. Have fun!


RE: send message withouth knowing windowhandle? by runarius on 07-23-2007 at 02:32 AM

thank you so much, that really helps me alot:D great respond time too:D


RE: send message withouth knowing windowhandle? by CookieRevised on 07-23-2007 at 02:46 AM

Deco is forgetting about:
- Checking your own status
- Checking if the Messenger object is available
- Checking the status of the contact
- Testing if you can send a message at all

Very important things you also must do...

And instead of doing the long iterating loop, you can use the GetContact function.

note: a Yahoo contact also has a prefix to its email.

;)


RE: send message withouth knowing windowhandle? by runarius on 07-23-2007 at 03:06 AM

hmm... could you help me with that? also, what I am trying to do now is just to save the contacts data to a textfile. But one of my contacts give me an error. This is the data I am trying to store:

<name>&#1178;*&#8236;&#8236;&#8236;&#8236;&#8236;&#8236;&#8236;&#8237;&#8300;&#8301;&#8301;&#8302;&#8303;&#8204;&#8205;isto&#1170;&#1170;er</name><email>pickupsrulz@hotmail.com</email><status>In a Call</status><pMsg></pMsg>

* After the first K in his name there is a wierd symbol that I can't show here. it is really a R with a circle around it.

I guess it is giving me the error becouse he is using an unusual sign, the R with the circle around it... anyway I could turn it into normal characters? don't think salling clicker supports wierd symbols, don't know really, but for now it would be great. or I could just manually check every message if they hold any odd symbols and then turn them into the right one, in this case, search for that odd looking R with the circle and replace it with a normal R.


RE: send message withouth knowing windowhandle? by matty on 07-23-2007 at 05:16 PM

You already asked that question in another thread and I provided the correct code.

Matty's reply to headache: Special characters.


RE: send message withouth knowing windowhandle? by mistertech on 07-25-2007 at 05:06 AM

Ok here's the simple way to send a message straight to a contact:


var contact = Messenger.OpenChat([email address]);
//variable contact is now an official ChatWnd object
contact.SendMessage([Message or variable to send]);
//message will be sent to the friend assigned to the variable


Keep in mind, this does not send messages to people who have not been added to your contact list yet.

As far as text files, there are some code snippets at

www.mpscripts.net

However I could not get them to work.(Didn't debug the code to figure out why; could be their code or mine).  You are looking for Windows Script Host functions.  They deal with files and the registry and many other things Windows related.  You'll find a link to the info on the functions in the Messenger Plus! Live Scripting Documentation under heading:
Objects Reference\MsgPlus Object\Properties\ScriptRegPath
Here is a direct link:

http://msdn2.microsoft.com/en-us/library/2x3w20xf.aspx

I hope it helps


RE: send message withouth knowing windowhandle? by CookieRevised on 07-25-2007 at 06:16 AM

quote:
Originally posted by mistertech
Ok here's the simple way to send a message straight to a contact:


var contact = Messenger.OpenChat([email address]);
//variable contact is now an official ChatWnd object
contact.SendMessage([Message or variable to send]);
//message will be sent to the friend assigned to the variable

Keep in mind, this does not send messages to people who have not been added to your contact list yet.
That code wil fail in many more situations though. You must do some additional checks. See my previous post. ;)