|  I've been thinking... | 
| Author: | 
Message: | 
whiz 
Senior Member 
    
  
 
Posts: 568 Reputation: 8 
– / – /   
Joined: Nov 2008 
 | 
O.P.    I've been thinking...
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...     
 |   
 | 
| 03-11-2010 08:26 PM | 
 | 
  | 
matty 
Scripting Guru 
     
  
 
Posts: 8327 Reputation: 109 
40 /   /   
Joined: Dec 2002
 
Status: Away
 
 | 
| 
 RE: I've been thinking...
 Yes it could. 
 |   
 | 
| 03-15-2010 12:54 PM | 
 | 
  | 
whiz 
Senior Member 
    
  
 
Posts: 568 Reputation: 8 
– / – /   
Joined: Nov 2008 
 | 
O.P.  RE: I've been thinking...
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 
    } 
}
   
 |   
 | 
| 03-17-2010 08:19 PM | 
 | 
  | 
Spunky 
Former Super Mod 
     
  
  
 
Posts: 3656 Reputation: 61 
37 /   /   
Joined: Aug 2006 
 | 
| 
 RE: I've been thinking...
 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 
<Eljay> "Problems encountered: shit blew up"    
 |   
 | 
| 03-17-2010 09:08 PM | 
 | 
  | 
whiz 
Senior Member 
    
  
 
Posts: 568 Reputation: 8 
– / – /   
Joined: Nov 2008 
 | 
O.P.  RE: I've been thinking...
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.     
 |   
 | 
| 03-18-2010 07:04 PM | 
 | 
  | 
CookieRevised 
Elite Member 
     
  
  
 
Posts: 15494 Reputation: 173 
– /   /   
Joined: Jul 2003
 
Status: Away
 
 | 
 RE: I've been thinking...
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.  
 This post was edited on 03-19-2010 at 11:30 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.  
 |   
 | 
| 03-19-2010 11:29 AM | 
 | 
  | 
Matti 
Elite Member 
     
  
  
Script Developer and Helper
  
Posts: 1646 Reputation: 39 
33 /   /   
Joined: Apr 2004 
 | 
 RE: I've been thinking...
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?    
 |   
 | 
| 03-19-2010 05:31 PM | 
 | 
  | 
Mnjul 
forum super mod 
      
  
  
plz wub me
  
Posts: 5396 Reputation: 58 
– /   /   
Joined: Nov 2002
 
Status: Away
 
 | 
 RE: I've been thinking...
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.  
 |   
 | 
| 03-19-2010 06:38 PM | 
 | 
  | 
Spunky 
Former Super Mod 
     
  
  
 
Posts: 3656 Reputation: 61 
37 /   /   
Joined: Aug 2006 
 | 
 RE: I've been thinking...
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...
  
<Eljay> "Problems encountered: shit blew up"    
 |   
 | 
| 03-19-2010 06:43 PM | 
 | 
  | 
Mnjul 
forum super mod 
      
  
  
plz wub me
  
Posts: 5396 Reputation: 58 
– /   /   
Joined: Nov 2002
 
Status: Away
 
 | 
 RE: I've been thinking...
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    
 |   
 | 
| 03-19-2010 07:11 PM | 
 | 
  | 
| 
Pages: (2): 
« First
  
 [ 1 ]
 2
 
»
 
Last »
 | 
| 
 |