Shoutbox

I've been thinking... - 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: I've been thinking... (/showthread.php?tid=94070)

I've been thinking... by whiz on 03-11-2010 at 08:26 PM

I've seen a few questions about an event for when an email is received.  And I remembered this.

If it's possible for a script to display the text from a popup, can a RegExp not be used to see if the toast contains the text "you have received an email from (...)" or "you have (...) new messages in your inbox"?

Just a thought...  :)


RE: I've been thinking... by matty on 03-15-2010 at 12:54 PM

Yes it could.


RE: I've been thinking... by whiz on 03-17-2010 at 08:19 PM

Something I just wrote out.  Except it doesn't seem to detect all types of events.  Any ideas?

js code:
// WLM Toasts - easily detect Messenger toasts
// By Whiz @ WhizWeb Community (http://www.portal-wwc.org.uk)

// Adapted from "MSN Popup Spy" by ".felipE" (http://felipex.net)

var Popups = []; // empty popup array
MsgPlus.AddTimer("WLMToastSearch", 100); // start a timer

function OnEvent_Timer(TimerId)
{
    if (TimerId === "WLMToastSearch")
    {
        var Popup = Interop.Call("user32", "FindWindowW", "msblpopupmsgwclass", 0); // attempt to find the window
        if (Popup && Popups[Popup.Handle] === undefined) // if it exists, and we haven't already dealt with it
        {
            var Length = Interop.Call("user32", "SendMessageA", Popup, 14, 0, 0); // get the length
            var String = ""; // start an empty string
            for (var Count = 0; Count < Length; Count++) // for each character of the length
            {
                String += " "; // add a space
            }
            Interop.Call("user32", "SendMessageW", Popup, 13, Length + 1, String); // get the actual message
            Debug.Trace("New WLM notification: \"" + String.replace(/\n/g, "") + "\" (handle: " + Popup.Handle + ")"); // add a debug message
            Popups[Popup.Handle] = String; // store the string and handle so that the toast isn't detected again
            // process "String" variable here
        }
        MsgPlus.AddTimer("WLMToastSearch", 100); // reset the timer
    }
}

RE: I've been thinking... by Spunky on 03-17-2010 at 09:08 PM

Using something like xniff this is a breeze, but I suppose it all depends if that's an option.

All I can think of for your problem is that maybe there are different classes for different types of events


RE: I've been thinking... by whiz on 03-18-2010 at 07:04 PM

It's difficult for me to test, since I don't have that many contacts, and I have Messenger Plus! event notifications for everything, but after changing a few settings, I have so far worked out that "<user> has just signed in" (contact online) notifications are detected, but "<user> says: <message>" (new message) notifications don't.

quote:
Originally posted by Spunky
All I can think of for your problem is that maybe there are different classes for different types of events
Possibly, but the "MSN Popup Spy" script that I based it on only searched for one class, and it seemed to detect all types of notifications.  :S
RE: I've been thinking... by CookieRevised on 03-19-2010 at 11:29 AM

quote:
Originally posted by whiz
var Popup = Interop.Call("user32", "FindWindowW", "msblpopupmsgwclass", 0); // attempt to find the window
if (Popup && Popups[Popup.Handle] === undefined) // if it exists, and we haven't already dealt with it
...

Popup is a simple numerical variable (which is already the handle of the window), it isn't a Plus! object. So it can't have the Handle property.
RE: I've been thinking... by Matti on 03-19-2010 at 05:31 PM

You might also want to make Popups an object instead of an array, like so:

js code:
var Popups = {};  // empty popups container object
The reason for this is that when you assign an element on a given index, the engine will have to create empty elements for all unassigned indexes before that index. You can see this for yourself with this sample code:
js code:
// Create empty array
var myArray = [];
// Set the 10th element in the array
myArray[9] = "foo";
// Now look what happens
Debug.Trace("Length="+myArray.length);
Debug.Trace("Joined="+myArray.join());
// Output:
// Length=10
// Joined=,,,,,,,,,foo
As you can see, indexes 0 to 8 have to be assigned to undefined before index 9 can be set. We don't need this at all, and when working with big index numbers such as window handles which can range from 0 to 2,147,483,647 this may turn out pretty nasty.

I could be wrong about this though, however I still find using arrays for this case inappropriate. I find it to be better practice to assign to an object property when you only need a collection of items and don't actually need a numbered list. It won't cost you in file size either, since {} takes up as much bytes as [], so why not? :P
RE: I've been thinking... by Mnjul on 03-19-2010 at 06:38 PM

quote:
Originally posted by Matti
the engine will have to create empty elements for all unassigned indexes before that index.
Actually no, JScript arrays are sparse. No empty elements are created. The "elements" of 0~8 in your example simply don't exist.
RE: I've been thinking... by Spunky on 03-19-2010 at 06:43 PM

quote:
Originally posted by Mnjul
quote:
Originally posted by Matti
the engine will have to create empty elements for all unassigned indexes before that index.
Actually no, JScript arrays are sparse. No empty elements are created. The "elements" of 0~8 in your example simply don't exist.


quote:
Originally posted by debug

Script is starting
Length=10
Joined=,,,,,,,,,foo


That's what I thought until I ran it...

RE: I've been thinking... by Mnjul on 03-19-2010 at 07:11 PM

Yeah, the length is 10 because the element with the largest index has index of 9, and join iterates from 0 to length-1, using empty strings for those undefined or null's - this doesn't contradict with what I said at all :p


RE: I've been thinking... by Matti on 03-19-2010 at 07:16 PM

Well, I wasn't sure about the inner workings of arrays, but still I believe that using an object here is better than an array. Why would you need to create an instance of an array when you're not planning to use any of the extra functionality it offers (such as length, push, pop, slice,...)? Still, I think it's an overkill, but perhaps that's just my opinion. :P


RE: I've been thinking... by whiz on 03-19-2010 at 08:06 PM

Fair enough, I'll change it later (I can't test it right now).

Any ideas for some events not working, though?