[Question]Remembering a ChatWnd |
Author: |
Message: |
MrR
New Member
Posts: 8
Joined: Dec 2007
|
O.P. [Question]Remembering a ChatWnd
Hey guys ^^
I started scripting in MP!L 2 days ago, and it's all going fine.
Today I tried to script an auto-message thingy, that basically has to send a message in an open chat window after awhile.
So I set a timer id, and a var to contain my message, but my problem is in the 'OnEvent_Timer' function. I just can't seem to create the ChatWnd so I could send the message. I tried saving the contact email and using Messenger.OpenChat, I also tried simply using a ChatWnd without defining. I tried countless variations of anything that refers to creating a ChatWnd in the documentation, and nothing seems to work.
So does anyone know how to save a ChatWnd \ ChatWnd identifier in a Var, so I could re-use it to send messages under the Timer function?
Thank you very much,
Roy.
|
|
12-12-2007 06:24 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: [Question]Remembering a ChatWnd
code: var ChatWnd = Messenger.OpenChat("email@hotmail.com");
ChatWnd.SendMessage(message);
Is that how you tried the code or different?
<Eljay> "Problems encountered: shit blew up"
|
|
12-12-2007 07:31 PM |
|
|
MrR
New Member
Posts: 8
Joined: Dec 2007
|
O.P. RE: [Question]Remembering a ChatWnd
That's what I did, replace the email in a var.
I think the problem is in the var, since when I told it to trace it it returned nothing (not null, just a line in the debugger containing NOTHING).
Is there any way to keep the hWnd and start a new chatwnd with it? That'd make things easier D:
|
|
12-12-2007 07:38 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: [Question]Remembering a ChatWnd
When someone talks to you, you can add the chatwnd object to an array, using the chatwnd's handle to identify it...
code: var myArray = new Array();
function OnEvent_ChatWndRecieveMessage(ChatWnd, Origin, Message){
myArray[ChatWnd.Handle] = ChatWnd;
}
Then in your timer you can tell it to send a message to all the chatwnds in the array. Obviously, you will want to check that it's specific people unless you want it to send to everybody that sends you a message
<Eljay> "Problems encountered: shit blew up"
|
|
12-12-2007 07:47 PM |
|
|
MrR
New Member
Posts: 8
Joined: Dec 2007
|
O.P. RE: [Question]Remembering a ChatWnd
Nevermind, problem solved.
I can't believe, as a programmer in other languages, that my mistake was so newbie (I don't have any background in JS )
I just had to set the var to the object itself.. myChat = ChatWnd.
And then use it in the other function.
Thanks alot, tho. Your array helped me think of the answer
|
|
12-12-2007 08:05 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: [Question]Remembering a ChatWnd
Lol, Glad I could help (in a round-about way)
<Eljay> "Problems encountered: shit blew up"
|
|
12-12-2007 08:17 PM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: [Question]Remembering a ChatWnd
Do NOT store the chat window handle, nor the object in a variable when you are going to use it later on.
Chat windows, like any window, can be closed. And closing a window means that your handle will become invalid and the object destroyed.
The proper way to do this is to store the contact's email address instead. When the time has come to send a message, you open up a chat window with that contact. If the 'old' chat window was never closed then it will be used again. If the chat window was closed, a new window will be created.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
12-12-2007 09:38 PM |
|
|
MrR
New Member
Posts: 8
Joined: Dec 2007
|
O.P. RE: [Question]Remembering a ChatWnd
But the usage I was looking for is immediate, and I want it, if needed, to send the message to the whole chatting group, and not only one of them.
|
|
12-12-2007 09:51 PM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: [Question]Remembering a ChatWnd
quote: Originally posted by MrR
But the usage I was looking for is immediate
Why are you using timers then? (see your first post)
Also: quote: Originally posted by MrR
That basically has to send a message in an open chat window after awhile.
Any delay (even 1 second) means you should not store the handle and the window objects.
quote: Originally posted by MrR
and I want it, if needed, to send the message to the whole chatting group, and not only one of them.
What do you mean by the "whole chatting group"?
This post was edited on 12-12-2007 at 10:25 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
12-12-2007 10:22 PM |
|
|
MrR
New Member
Posts: 8
Joined: Dec 2007
|
O.P. RE: [Question]Remembering a ChatWnd
quote: Originally posted by CookieRevised
quote: Originally posted by MrR
But the usage I was looking for is immediate
Why are you using timers then? (see your first post)
Cause I want it to output it several times
quote: Originally posted by CookieRevised
Also:quote: Originally posted by MrR
That basically has to send a message in an open chat window after awhile.
Any delay (even 1 second) means you should not store the handle and the window objects.
Well I ensure you that if I'll dispose the window in the middle I won't need the script in a first place. ^^
quote: Originally posted by CookieRevised
quote: Originally posted by MrR
and I want it, if needed, to send the message to the whole chatting group, and not only one of them.
What do you mean by the "whole chatting group"?
I mean to all of the people in the same chat window I was using, basically to the same window so whoever in it will see it.
|
|
12-13-2007 06:06 AM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|