Shoutbox

Toast Box Help - 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: Toast Box Help (/showthread.php?tid=63662)

Toast Box Help by Vexor on 07-20-2006 at 11:03 AM

code:
function OnEvent_ChatWndCreated(Origin)
{
if (Origin = Messenger.MyName)
{
MsgPlus.DisplayToastContact(Origin ,"Opened a Chat Window With", Origin ,"CHIMES.WAV");
}
}


Ok you can see what code I have, now, I am trying to get it so that My name shows up at the top of the Toast Box (does that fine), Has a message (does that fine), and also shows the name of the person that I open a ChatWindow with (That I have spend 3 days trying to do. and it wont)

can someone help me?

code:
Vexor

Opened a Chat Window With
Contact


That is what I want it to basically look like.
RE: Toast Box Help by markee on 07-20-2006 at 11:20 AM

Try this instead

code:
function OnEvent_ChatWndCreated(ChatWnd)
{
var ChatWndContacts = ChatWnd.Contacts;
  if(ChatWndContacts.Count == 1)
  {
    var e = new Enumerator(ChatWndContacts);
    var Contact = e.item();
{
MsgPlus.DisplayToastContact(Messenger.MyName ,"Opened a Chat Window With", Contact.Name ,"CHIMES.WAV");
}
}
}
Though it doesn't matter if it is you or your contact that creates the window it will always say it's you.  I really don't know how to change this so it only happens on you opening the chat window (like i think you want gthered by your code)

EDIT: Ddunk's post explains it better and so does his code, I just used the DisplayToastContact because I keep forgetting how to do the extra line stuff :P also I have it only come up if there is only one contact in the chat (this is done by the fourth line)
RE: Toast Box Help by ddunk on 07-20-2006 at 11:21 AM

K, you have a few problems we need to address.

quote:
Originally posted by Vexor
function OnEvent_ChatWndCreated(Origin)
OnEvent_ChatWndCreated doesn't have an Origin parameter, just ChatWnd.
quote:
Originally posted by Vexor
if (Origin = Messenger.MyName)
If you're comparing two things, use == instead of =. But this if statement isn't needed anyway because there's no Origin to check.
quote:
Originally posted by Vexor
MsgPlus.DisplayToastContact(Origin ,"Opened a Chat Window With", Origin ,"CHIMES.WAV");
With that, you're saying "Open a toast with the title 'Origin' (which doesn't exist), have text of 'Opened a Chat Window With', play the sound 'Origin' and run the function 'CHIMES.WAV' when you click the toast." Also, you don't need to use DisplayToastContact. Ignore that, didn't realize DisplayToastContact used different params. :P I'd still suggest using DisplayToast instead.

code:
function OnEvent_ChatWndCreated(ChatWnd)
{
    var Contacts = ChatWnd.Contacts; //Get names of contacts in newly created window.
    var e = new Enumerator(Contacts); //iterate ChatWnd.Contacts (see: http://m00.cx/mpl/docs/ref-contacts-iterator.htm)
    var Contact = e.item();
    MsgPlus.DisplayToast(Messenger.MyName,"Opened a Chat Window With\n" + Contact.Email,"CHIMES.WAV"); //create the toast.
}
(Won't work with multi-user convos, but it works fine for the creating of a single person window. However, this toast will appear when someone sends a message to you if you do not have a window open with them before.)

EDIT: Use markee's script because I was too lazy to add a ChatWnd.Count check. My above points still stand though :P

EDIT2:
code:
function OnEvent_ChatWndCreated(ChatWnd)
{
    var ChatWndContacts = ChatWnd.Contacts;
    if(ChatWndContacts.Count == 1)
    {
        var e = new Enumerator(ChatWndContacts);
        var Contact = e.item();
         MsgPlus.DisplayToast(Messenger.MyName,"Opened a Chat Window With\n" + Contact.Email,"CHIMES.WAV");
    }
}

Use that.
RE: Toast Box Help by Vexor on 07-20-2006 at 11:29 AM

Thankx Markee that seems to work for now..

Ddunk, I looked as the link you sent and it was just more confuzing.. and with the

code:
function OnEvent_ChatWndCreated(Origin)
in there it seemed to work with it having

code:
vexor

has opened a chat windows with
vexor


so it worked, just did not (no matter what i changed or what way i went) allow me to have a contacts name, and with origin not in this
code:
function OnEvent_ChatWndCreated(Origin)
it did not work at all.
RE: Toast Box Help by ddunk on 07-20-2006 at 11:32 AM

quote:
Originally posted by Vexor
in there it seemed to work with it having
The reason it worked was because with "Origin = Messenger.MyName", you were setting the variable 'Origin' to be Messenger.MyName.
RE: Toast Box Help by Vexor on 07-20-2006 at 11:33 AM

that might be why.. but thank you anyway.


RE: Toast Box Help by markee on 07-20-2006 at 11:39 AM

I think I can make something to show it from the different contacts, all depending on if your contact sent you the message, but that is going to become longer.  I'll try it out for you and see what I can do for you.

Btw Ddunk

quote:
Originally posted by Ddunk
With that, you're saying "Open a toast with the title 'Origin' (which doesn't exist), have text of 'Opened a Chat Window With', play the sound 'Origin' and run the function 'CHIMES.WAV' when you click the toast." Also, you don't need to use DisplayToastContact. Ignore that, didn't realize DisplayToastContact used different params. (Smilie) I'd still suggest using DisplayToast instead.
Really it only needed the DisplayToast, the difference between them is that DisplayToastContact allows you to have the likes of colour, bold, italics, etc in the first line and automatically puts the next lot of quotes on the next line.
RE: Toast Box Help by Vexor on 07-20-2006 at 11:53 AM

Now is there a way to get it to show when a contact opens a chat with you,

code:
ContactName
Has opened a chat with you.

This will be useful, As I have my toasts so that they are visable while I am in some games, and if I can see when a contact opens a chat window with me, then I can Minimize the game to talk if i want to talk to that person..
RE: Toast Box Help by markee on 07-20-2006 at 01:02 PM

This should do what you want it to do, though I haven't been able to test it when a contact opens a message I must say (all are either offline or I dont want to talk to them anyway :P).  I trust that part of the code anyway.  I hope you like it.  I must also add that this script does not show when they open a window with you but more when they send you a message which opens a window on your computer.

code:
var cont;
function OnEvent_ChatWndCreated(ChatWnd)
{
var ChatWndContacts = ChatWnd.Contacts;
  if(ChatWndContacts.Count == 1)
  {
    var e = new Enumerator(ChatWndContacts);
    var Contact = e.item();
    cont = 1
    MsgPlus.AddTimer('TimerId', '100')
  }
}

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
  if (cont == 1)
  {
    MsgPlus.DisplayToastContact(Contact.Name ,"Opened a Chat Window With", Messenger.MyName ,"CHIMES.WAV");
    cont = ''
  }
}

function OnEvent_Timer(TimerId)
{
  if (TimerId == "TimerId")
  {
    if (cont == 1)
    {
      var Windows = Messenger.CurrentChats;
      var e = new Enumerator(Windows);
      for(; !e.atEnd(); e.moveNext())
      {
        var ChatWnd = e.item();
        var ChatWndContacts = ChatWnd.Contacts;
        if(ChatWndContacts.Count == 1)
        {
          var e = new Enumerator(ChatWndContacts);
          var Contact = e.item();
          MsgPlus.DisplayToastContact(Messenger.MyName ,"Opened a Chat Window With", Contact.Name ,"CHIMES.WAV");
          cont = ''
        }
      }
    }
  }
}
Hope it's what you were looking for. :)
RE: Toast Box Help by Vexor on 07-20-2006 at 01:24 PM

Na it only toasts when i open a chat window form my start bar.


RE: Toast Box Help by markee on 07-20-2006 at 01:38 PM

Ok well again I haven't had a chance to test it but I think the problem was mostly how I set it out (should have had the 'cont = 1' at the begining) I have also added another timer to just make sure there is no problems.  I don't think there should be any more problems but I can't be assured of that, sorry.

code:
var cont;
function OnEvent_ChatWndCreated(ChatWnd)
{
  cont = 1
  var ChatWndContacts = ChatWnd.Contacts;
  if(ChatWndContacts.Count == 1)
  {
    var e = new Enumerator(ChatWndContacts);
    var Contact = e.item();
    Debug.Trace('1')
    MsgPlus.AddTimer('TimerId', '500')
  }
}

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
  Debug.Trace('2')
  MsgPlus.AddTimer('TimerId2','100')
}

function OnEvent_Timer(TimerId)
{
  if (TimerId == "TimerId")
  {
    Debug.Trace('/1')
    if (cont == 1)
    {
      var Windows = Messenger.CurrentChats;
      var e = new Enumerator(Windows);
      for(; !e.atEnd(); e.moveNext())
      {
        var ChatWnd = e.item();
        var ChatWndContacts = ChatWnd.Contacts;
        if(ChatWndContacts.Count == 1)
        {
          var e = new Enumerator(ChatWndContacts);
          var Contact = e.item();
          MsgPlus.DisplayToastContact(Messenger.MyName ,"Opened a Chat Window With", Contact.Name,"CHIMES.WAV");
          cont = ''
        }
      }
    }
  }
  if (TimerId == "TimerId2")
  {
      if (cont == 1)
      {
        Debug.Trace('/2')
        MsgPlus.CancelTimer('TimerId')
        var Windows = Messenger.CurrentChats;
        var e = new Enumerator(Windows);
        for(; !e.atEnd(); e.moveNext())
        {
          var ChatWnd = e.item();
          var ChatWndContacts = ChatWnd.Contacts;
          if(ChatWndContacts.Count == 1)
          {
            var e = new Enumerator(ChatWndContacts);
            var Contact = e.item();
            MsgPlus.DisplayToastContact(Contact.Name ,"Opened a Chat Window With", Messenger.MyName ,"CHIMES.WAV");
            cont = ''
          }
        }
      }
  }
}
EDIT:Sorry I finally got to test it and had to change a timer, hope you like it (should all work for you now)