What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin

Pages: (2): « First « 1 [ 2 ] Last »
[Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin
'DisabledFor' is only created when you disable/enable StuffPlug. Before that it indeed doesn't exist... This is fixed (in a shorter/elegant way) in my code.

PS: there is a reason why I used equality operators instead of identity operators though. Don't change that or the function will fail again in some (very rare) cases. ;)

This post was edited on 01-22-2007 at 06:21 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
01-22-2007 05:00 AM
Profile PM Find Quote Report
bigbob85
Full Member
***

Avatar
Is Good, Is Bob...

Posts: 128
Reputation: 4
36 / Male / Flag
Joined: Jul 2003
RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin
CookieRevised, what sort of instances would it fail?
12-14-2007 10:49 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin
RegRead can return other stuff than integers. It depends on the registry key type. So, if the user (for whatever reason) had manually changed the reg key type to a string (which is VERY common actually in scripts made by newbies), then the string "1" is not the same as the number 1 when you use identity operators (===).

When you use an equality operator (==) then the string "1" is the same as 1.

So, if somebody made a script which doesn't take in account that the registry key 'ChatName' is supposed to be of the REG_DWORD type (instead of a REG_SZ) when you change/write the value, then Markee's script will fail.

This post was edited on 12-14-2007 at 11:55 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-14-2007 11:52 PM
Profile PM Find Quote Report
bigbob85
Full Member
***

Avatar
Is Good, Is Bob...

Posts: 128
Reputation: 4
36 / Male / Flag
Joined: Jul 2003
RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin
Ah ok. Makes sense.
Any idea if this is the same in C/C++/Java? Did first year of uni so far, and I know of the ===  and I knew it was more strict or something, but we never learnt them in Java or C/C++...
Maybe they were just trying not to confuse the newbie programmers there...
[Image: signature-user=16&back=2&clr=0,0,0&size=100.png]
12-15-2007 12:16 AM
Profile E-Mail PM Web Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
Joined: Jan 2006
O.P. RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin
The === is the same in all languages to the best of my knowledge.  And I believe you still have to specify how the variable is stored in the registry, however you can make a fix with stuff like a function to do it for you and using typeOf method with a switch statement (but this can wait for another thread ;)).
[Image: markee.png]
12-15-2007 05:16 AM
Profile PM Find Quote Report
Deco
Full Member
***


Posts: 188
Reputation: 4
41 / Male / Flag
Joined: Aug 2006
RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin
Cookie,
that check you sent using message compare will fail with a simple "hi". Maybe you could use all three types sent in so far. Use deads boolean , the check user name and then compare the message. I guess that would make it very unlikely to fail.
Have fun!
[Image: signature-user=31&back=4&clr=106,141,166&size=100.png]
12-16-2007 11:30 AM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin
quote:
Originally posted by markee
I believe you still have to specify how the variable is stored in the registry
You should, but you don't need to. And that is exactly what many new scripters forget to do. When you don't do it and depending on how you've set up the variable or what method you use to write to the registry, it can revert back to the default REG_SZ, a string, not REG_DWORD, a number, for example.

And that is exactly why I didn't use an identity (===) operator, but a equality (==) operator, because you don't know what _other_ scripts have done with that value...

Bottom line:
When reading something from the registry: always use a equality operator, or use a similar function to handle unexpected types.
When writing to the registry: always define the correct type of the value, and don't trust upon 'default' settings.


quote:
Originally posted by Deco
Cookie,
that check you sent using message compare will fail with a simple "hi".
how?

quote:
Originally posted by Deco
Maybe you could use all three types sent in so far. Use deAd's boolean
His code, unfortunatly, will fail in more situations and should not be used, even not together with other methods (discussed before).

Not only will it fail when a message is recieved between you sending a message and Messenger putting your message in the chat window (which is rare, but it CAN happen; the busier you are chatting with different people at the same time, the more chance you have this will happen).

But the chance of failing will be extremely bigger when you have more than one chat going on (which is far from rare), since he used just 1 global variable for checking every possible chat window.

If you want to use a simply, easy method, use the second snipped I posted. As you will see it is basically the exact same thing as what deAd did, but it handles individual chats properly and thus will work with multipe chats. Though, it still would fail if a message is recieved between you sending a message and Messenger putting it in the chat.

(note: the snippet is just that: a snippet outlining the method. You do need to add some more things like removing the array items when a chat is closed, etc to implement it properly).

This post was edited on 12-16-2007 at 03:09 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-16-2007 01:18 PM
Profile PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
Joined: Jan 2006
O.P. RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin
quote:
Originally posted by CookieRevised
You should, but you don't need to. And that is exactly what many new scripters forget to do.
I meant in other code languages.... :P

quote:
Originally posted by Deco
Cookie,
that check you sent using message compare will fail with a simple "hi". Maybe you could use all three types sent in so far. Use deads boolean , the check user name and then compare the message. I guess that would make it very unlikely to fail.
Have fun!
I advise you not to do that, the message check of Cookie's is reliable, whereas deAd's and the name check method can fail.  Well Cookie's can too, but only when you and the contact in the message send the exact same message, but their's is recieved between your sent message and recieving it back.  But that is a far more extreme case (and deAd's method woul also fail in these circumstances, plus more).  As or the name checking, that can easily be fooled (if you contact steals your name or you use stuff plug for example).  And you cannot combine these in any way either so there is no point, otherwise you just get conflicting ideas....
[Image: markee.png]
12-16-2007 01:49 PM
Profile PM Find Quote Report
bigbob85
Full Member
***

Avatar
Is Good, Is Bob...

Posts: 128
Reputation: 4
36 / Male / Flag
Joined: Jul 2003
RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin
What if you check contact name? Will the on recieve msg show their chat only name or the same name from the main messenger window?

I expect this wont work since no one else has said it yet.

EDIT:
Nevermind..

quote:
Script is starting
Script is now loaded and ready
Function called: OnEvent_Initialize
Function called: OnEvent_ChatWndReceiveMessage
Receive Message
Origin - The "Using Chat-Only Name" Bradley
Iteration - The "Showering" Bradley - I (L) BangBang

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
      Debug.Trace("Receive Message");
      Debug.Trace("Origin - "+Origin);
      var Contacts = ChatWnd.Contacts;
      var e = new Enumerator(Contacts);
      for(; !e.atEnd(); e.moveNext())
      {
            var Contact = e.item();
            Debug.Trace("Iteration - " +Contact.Name);
      }
      Debug.Trace("----------------");
}

This post was edited on 12-17-2007 at 03:41 AM by bigbob85.
[Image: signature-user=16&back=2&clr=0,0,0&size=100.png]
12-16-2007 10:28 PM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] 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