What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » How to - Clicking toast to bring up contact list?

How to - Clicking toast to bring up contact list?
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: How to - Clicking toast to bring up contact list?
The above code is not polygamy safe. This means that you will get in trouble if you have more than one Messenger client open. To make it polygamy safe/compatible:

code:
// First, define a callback function for the toast click.
function OnToastClick() {
    // In this function, we will show the contact list (POLYGAMY SAFE).
    // To do this, we will tell the tray icon listener window that it has been double clicked.
    var hWnd = 0;
    var tIDCurrent = Interop.Call('Kernel32', 'GetCurrentThreadId');
    while (hWnd = Interop.Call('User32', 'FindWindowExW', 0, hWnd, 'MSNHiddenWindowClass', 0)) {
        if (Interop.Call('User32', 'GetWindowThreadProcessId', hWnd, 0) === tIDCurrent) {
            // If the hidden window was found, tell it we double clicked the tray icon
            Interop.Call('User32', 'SendMessageW', hWnd, /* REGISTERED MSG */ 0xC350, 0, /* WM_LBUTTONDBLCLK */ 0x203);
            break;
        }
    }
    /*
        // Another method is to use the MSNMSGRBlObj class instead:
        var hWnd = 0;
        var tIDCurrent = Interop.Call('Kernel32', 'GetCurrentThreadId');
        while (hWnd = Interop.Call('User32', 'FindWindowExW', 0, hWnd, 'MSNMSGRBlObj', 0)) {
            if (Interop.Call('User32', 'GetWindowThreadProcessId', hWnd, 0) === tIDCurrent) {
                Interop.Call('User32', 'SendMessageA', hWnd, 0x42A, 0, 0);
                break;
            }
        }

    */
}

// Now, all we need to do is create a toast with this callback function.
function ShowToast() {
    MsgPlus.DisplayToast('Example', 'Click here!', null, 'OnToastClick', null);
}

If you do stuff with windows like that (eg: sending messages to specific Messenger windows etc), always keep it mind that windows are not unique and that two or more windows of the same kind (class) can exist!

So to avoid that you do stuff with the wrong window, you need to check if the window belongs to the thread you seek. And since scripts are run within the same thread as Messenger, you can simply compare the current thread (which is the one from the script) with the thread of the window. If they are the same you have found the correct window. If the thread id is different you may have found a window with the same class, but it would belong to another Messenger client in this case.

;)

This post was edited on 06-25-2007 at 02:41 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
06-25-2007 02:33 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
How to - Clicking toast to bring up contact list? - by stu on 06-24-2007 at 09:51 PM
RE: How to - Clicking toast to bring up contact list? - by deAd on 06-24-2007 at 10:55 PM
RE: How to - Clicking toast to bring up contact list? - by stu on 06-24-2007 at 11:10 PM
RE: How to - Clicking toast to bring up contact list? - by CookieRevised on 06-25-2007 at 02:33 AM
RE: How to - Clicking toast to bring up contact list? - by stu on 06-25-2007 at 02:51 AM


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