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:
stu
Junior Member
**

Avatar
Stu

Posts: 82
Reputation: 1
39 / Male / Flag
Joined: Sep 2004
O.P. How to - Clicking toast to bring up contact list?
For a script that I have been working on, I have it display a toast. How do I set it up so that when you click on this toast, it will open the contact list?

This post was edited on 06-24-2007 at 10:11 PM by stu.
06-24-2007 09:51 PM
Profile E-Mail PM Web Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: How to - Clicking toast to bring up contact list?
code:
// First, define a callback function for the toast click.
function OnToastClick(pParam){
    // In this function, we will show the contact list.
    // To do this, we will tell the tray icon listener window that it has been double clicked.
    // First we need a handle to the tray listener window.

    var hListener = Interop.Call('User32', 'FindWindowW', 'MSNHiddenWindowClass', 0);
    if(hListener){ // Check if the window was found.
        Interop.Call('User32', 'SendMessageW', hListener, 0xC350, 0, 0x203); // Tell the listener that it was clicked.
    }
}

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

This post was edited on 06-24-2007 at 10:56 PM by deAd.
06-24-2007 10:55 PM
Profile PM Find Quote Report
stu
Junior Member
**

Avatar
Stu

Posts: 82
Reputation: 1
39 / Male / Flag
Joined: Sep 2004
O.P. RE: How to - Clicking toast to bring up contact list?
Thanks :)
06-24-2007 11:10 PM
Profile E-Mail PM Web Find Quote Report
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
stu
Junior Member
**

Avatar
Stu

Posts: 82
Reputation: 1
39 / Male / Flag
Joined: Sep 2004
O.P. RE: How to - Clicking toast to bring up contact list?
Ok, thanks Cookie, may have had issue later on down the road. I am only using this for a script I made to display a random lyric in my personal message, and it also displays a toast with the lyric, so not a huge deal, but I guess you never know.
06-25-2007 02:51 AM
Profile E-Mail PM Web Find Quote Report
« 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