What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Simple Problem w/ Objects

Simple Problem w/ Objects
Author: Message:
Cetanu
New Member
*

Avatar

Posts: 5
30 / Male / Flag
Joined: Sep 2009
O.P. Simple Problem w/ Objects
I am looking to use SendMessage if someone messages me when I am Busy or Away, but I don't know how to create an object of ChatWnd. Could someone please explain what it means (and how to) to create an object of ChatWnd.


I know that creating an object of global things involves something like Messenger.MyName, but I dunno what to do with ChatWnd, and it's driving me crazy. Thanks!
"You stormed off to scar the armada
Like Jesus played martyr
I'll drill through your hands"

- Coheed and Cambria
09-15-2009 02:34 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Simple Problem w/ Objects
Have a look at this thread for some useful information. Script Always Stopped
09-15-2009 02:45 PM
Profile E-Mail PM Find Quote Report
Cetanu
New Member
*

Avatar

Posts: 5
30 / Male / Flag
Joined: Sep 2009
O.P. RE: Simple Problem w/ Objects
That's great! THANKS A LOT!
"You stormed off to scar the armada
Like Jesus played martyr
I'll drill through your hands"

- Coheed and Cambria
09-15-2009 02:50 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Simple Problem w/ Objects
No problem, glad it cleared up the confusion for you :)
09-15-2009 02:58 PM
Profile E-Mail PM Find Quote Report
Cetanu
New Member
*

Avatar

Posts: 5
30 / Male / Flag
Joined: Sep 2009
O.P. RE: Simple Problem w/ Objects
There is one more thing I forgot:

If I were to have a code like this: (outline, not actual code)
if (I am busy){
if(I receive a message){
SendMessage("I'm doing ______");
}
}

That's not the syntax, just the point. :D But how would I do that since SendMessage requires a ChatWnd object... >.> Maybe I just missed it in that thread; I'll read again, but help is still appreciated. :)


Edit: I do think I missed it, since this was the question I asked before, I just forgot that I asked it.

This post was edited on 09-15-2009 at 05:19 PM by Cetanu.
"You stormed off to scar the armada
Like Jesus played martyr
I'll drill through your hands"

- Coheed and Cambria
09-15-2009 05:18 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Simple Problem w/ Objects
The function OnEvent_ChatWndMessageReceive has a parameter called pChatWnd. This is the Chat Window where the event happened. Therefore you could do something like this:

js code:
var oChatWnds = {}; // variable to hold the chat window handles and the messages we send to make sure we are not sending the message causing infinite loops

function OnEvent_ChatWndSendMessage ( pChatWnd , sMessage )
{
    oChatWnds [ pChatWnd.Handle ] = sMessage; // add the message to the object
}

function OnEvent_ChatWndReceiveMessage ( pChatWnd , sOrigin , sMessage , nMessageKind )
{
    if ( oChatWnds [ pChatWnd.Handle ] === sMessage ) return sMessage; // Since we just send this message we can ignore it
   
    if ( Messenger.MyStatus === STATUS_BUSY ) // check if your status is busy
    {
        pChatWnd.SendMessage ( 'I currently am busy and cannot reply. Thank you for your paitence.' ); // if it is busy then send a message
    }
}

function OnEvent_ChatWndDestroyed ( pChatWnd )
{
    delete oChatWnds [ pChatWnd.Handle ]; // delete the message from our storage object
}
09-15-2009 05:45 PM
Profile E-Mail PM Find Quote Report
Cetanu
New Member
*

Avatar

Posts: 5
30 / Male / Flag
Joined: Sep 2009
O.P. RE: Simple Problem w/ Objects
Has anyone referred to you as a deity?

^_^ THANKS! It worked...I wouldn't be able to accomplish that with my knowledge of JS.
"You stormed off to scar the armada
Like Jesus played martyr
I'll drill through your hands"

- Coheed and Cambria
09-15-2009 06:02 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Simple Problem w/ Objects
No problem it is what we are here for. There have been a lot of discussion surrounding the best way to programmatically tell who sent what message through Plus! Scripting. The sad thing is is that Plus! has no way of knowing the email of the contact; only their name. With that said this is the easiest way of knowing if you sent the message. If the messages do not match well than you know you didn't send it.
09-15-2009 06:36 PM
Profile E-Mail PM Find Quote Report
Cetanu
New Member
*

Avatar

Posts: 5
30 / Male / Flag
Joined: Sep 2009
O.P. RE: Simple Problem w/ Objects
Well, thanks. :) I've used this code so much already....XD
"You stormed off to scar the armada
Like Jesus played martyr
I'll drill through your hands"

- Coheed and Cambria
09-15-2009 08:32 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Simple Problem w/ Objects
quote:
Originally posted by matty
With that said this is the easiest way of knowing if you sent the message. If the messages do not match well than you know you didn't send it.
Unfortunatly, I see you use that kind of approach in many example codes of yours. Although it would work in theory, it is not implemented properly in any of your example codes and thus will not work properly!

You will get into trouble when the contact sends the same message (at a certain point in time) as you last did:

You: Type the next command to initiate the transfer:
You: !start
Contact: Ah, ok, thanks. I'l send the command now
Contact: !start
Contact: nothing happened :(
You: Hmm, the code in OnEvent_ChatWndReceiveMessage was never executed...
...

^^ the above scenario will show exactly what I mean...

To solve that you must delete oChatWnds[pChatWnd.Handle] before you return with sMessage in OnEvent_ChatWndReceiveMessage
js code:
function OnEvent_ChatWndReceiveMessage(pChatWnd, sOrigin, sMessage, nMessageKind ) {
    if (oChatWnds[pChatWnd.Handle] === sMessage ) {
        >>>delete oChatWnds[pChatWnd.Handle];<<<
        return sMessage; // Since we just send this message we can ignore it
    }
    ...
}

;)

This post was edited on 11-23-2009 at 10:25 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
11-23-2009 09:47 PM
Profile PM 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