What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Help with some code

Pages: (3): « First [ 1 ] 2 3 » Last »
Help with some code
Author: Message:
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
32 / Male / Flag
Joined: Jul 2006
O.P. Help with some code
At the moment i got this:
code:
function OnEventMessenger.Signin
{
chatwnd.sendmessage('hi')
{
{



i want it to send a message to all online contacts when i sign in. Why isn't it working
10-02-2006 05:21 PM
Profile E-Mail PM Find Quote Report
saralk
Veteran Member
*****

Avatar

Posts: 2598
Reputation: 38
35 / Male / Flag
Joined: Feb 2003
RE: Help with some code
Firstly the function is OnEvent_Signin()

Secondly, ChatWnd.SendMessage only sends to the currently active window. I'm not going to write the code for you, but it'd be pretty simple to do.

code:
OnEvent_Signin(Email) {
//code
}

you would need to make the code iterate through every contact using Messenger.MyContacts

Actually, change of mind, i'll write it for you, but i wont test it or anything...

code:
OnEvent_Signin(Email) {
Debug.Trace("Contacts in the user's contact list:");
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext())
{
    var Contact = e.item();
    if (Contact.Status != 1) {
                    Messenger.OpenChat(Contact);
                    ChatWnd.SendMessage("MESSAGE");
         }
}
}

P.S. This is pretty basic stuff, most of the code was in the help files. I reccomend you a) look at the help files before asking for help and b) get a book teaching you javascript.

This post was edited on 10-02-2006 at 05:46 PM by saralk.
The Artist Formerly Known As saralk
London · New York · Paris
Est. 1989
10-02-2006 05:44 PM
Profile PM Find Quote Report
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
32 / Male / Flag
Joined: Jul 2006
O.P. RE: RE: Help with some code
What do you mean by this:

code:
OnEvent_Signin(Email) {
Debug.Trace("Contacts in the user's contact list:");
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext())
{
    var Contact = e.item();
    if (Contact.Status != 1) {
                    Messenger.OpenChat(Contact);
                    ChatWnd.SendMessage("MESSAGE");
         }
}
}
10-02-2006 05:46 PM
Profile E-Mail PM Find Quote Report
saralk
Veteran Member
*****

Avatar

Posts: 2598
Reputation: 38
35 / Male / Flag
Joined: Feb 2003
RE: Help with some code
I just copied a load of the code from the built in help files, and so some of that code is left over.

Debug.Trace is a way of putting the files in the debugging box. Which you can activate by checking the option box from the scripts menu.
Developers use the trace as an easy way of finding out what is wrong with their code, for example if a bit of code such as
code:
if (Var1 == Var2) { ... }
didn't work, the developer might put
code:
Debug.Trace(Var1); Debug.Trace(Var2);
so they can find out if the variables are indeed the same.
The Artist Formerly Known As saralk
London · New York · Paris
Est. 1989
10-02-2006 05:51 PM
Profile PM Find Quote Report
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
32 / Male / Flag
Joined: Jul 2006
O.P. RE: Help with some code
Oh, ok. Thanks Saralk
EDIT: One last quick question, can scripts check if a certain person is online ans if they are, it automatically sends a message to them?

This post was edited on 10-02-2006 at 05:55 PM by Jimbo.
10-02-2006 05:53 PM
Profile E-Mail PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: Help with some code
134jimbodude, you can. Off the top of my head:
code:
var sEmail = "email@address.com";
var oContact = Messenger.MyContacts.GetContact(sEmail);
if(oContact.Status != 1){
                    var ChatWnd = Messenger.OpenChat(sEmail);
                    ChatWnd.SendMessage("hi");
}

quote:
Originally posted by saralk
Secondly, ChatWnd.SendMessage only sends to the currently active window.
No. It sends a message to whatever window the variable "ChatWnd" is assigned to.

quote:
Originally posted by saralk
get a book teaching you javascript.
Plus! uses JScript. JScript is not javascript. You can find the JScript documentation on MSDN.

This post was edited on 10-02-2006 at 06:12 PM by deAd.
10-02-2006 06:09 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Help with some code
quote:
Originally posted by saralk
code:
OnEvent_Signin(Email) {
Debug.Trace("Contacts in the user's contact list:");
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext())
{
    var Contact = e.item();
    if (Contact.Status != 1) {
                    Messenger.OpenChat(Contact);
                    ChatWnd.SendMessage("MESSAGE");
         }
}
}

correction:
code:
OnEvent_Signin(Email) {
Debug.Trace("Contacts in the user's contact list:");
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext())
{
    var Contact = e.item();
    if (Contact.Status != 1) {
                    var ChatWnd = Messenger.OpenChat(Contact);
                    if (ChatWnd.EditChangeAllowed) ChatWnd.SendMessage("MESSAGE");
       }
}
}

quote:
Originally posted by 134jimbodude
Oh, ok. Thanks Saralk
EDIT: One last quick question, can scripts check if a certain person is online ans if they are, it automatically sends a message to them?
yes

what saralk's code does is:

1) get the object which holds all your contacts (var Contacts = Messenger.MyContacts;)

2) iterate thru each contact (enumeration and the for loop) and check if they are online (if (Contact.Status != 1))

3) open a chat window (Messenger.OpenChat(Contact);)

4) send the message (ChatWnd.SendMessage("MESSAGE");)

So instead of only checking all your contacts if they are online or not, also check the email of the contact you currently are iterating and only send the message if it is the one you need.

Another (shorter) way is to do what dead showed. This is actually turning it around and instead of checking all the contacts, directly look up the contact you need.

This post was edited on 10-02-2006 at 06:18 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
10-02-2006 06:11 PM
Profile PM Find Quote Report
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
32 / Male / Flag
Joined: Jul 2006
O.P. RE: Help with some code
But i want it to only work for certain contacts if they are online, not all contacts, is this possible
quote:
Originally posted by CookieRevised

so instead of messaging all the online contacts, also check the email the the contact object and only send the message if it is the one you need.

How would i do this?

This post was edited on 10-02-2006 at 06:14 PM by Jimbo.
10-02-2006 06:13 PM
Profile E-Mail PM Find Quote Report
saralk
Veteran Member
*****

Avatar

Posts: 2598
Reputation: 38
35 / Male / Flag
Joined: Feb 2003
RE: Help with some code
quote:
Originally posted by deAd
Plus! uses JScript. JScript is not javascript. You can find the JScript documentation on MSDN.

Well you learn something new every day (I tought myself JScript using the examples from the Plus! documentation)

quote:
Originally posted by 134jimbodude
But i want it to only work for certain contacts if they are online, not all contacts, is this possible

Do you mean if a certain contact from a prespecified list?

This post was edited on 10-02-2006 at 06:15 PM by saralk.
The Artist Formerly Known As saralk
London · New York · Paris
Est. 1989
10-02-2006 06:14 PM
Profile PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: Help with some code
Cookie, I believe 134jimbodude wants to check for a specific contact instead of all of them. The code I posted above should do that. Instead of looping through them, when you know the email it is better to just find that one exactly.
EDIT: you already updated your post :sad:

Also, saralk's code will not work. the ChatWnd variable is undefined and the message will not be sent...(just add "var ChatWnd = " before the OpenChat part and it'll work again)

This post was edited on 10-02-2006 at 06:16 PM by deAd.
10-02-2006 06:15 PM
Profile PM Find Quote Report
Pages: (3): « First [ 1 ] 2 3 » Last »
« 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