What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Link on toast window

Link on toast window
Author: Message:
Roli_
New Member
*


Posts: 5
Joined: Jun 2006
O.P. Link on toast window
how to put a link on a toast window?
07-04-2006 02:19 PM
Profile E-Mail PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Link on toast window
You mean, you want something to happen when you click the toast of your script?

if so:
code:
[boolean] DisplayToast(
    [string] Title,
    [string] Message,
    [string,optional] SoundFile,
    [string,optional] Callback,
    [var,optional] CallbackParam
);

Callback is the function it will call when clicked and the CallbackParam  is the parameter sent to it, so you make one like this for example:

code:
MsgPlus.DisplayToast("TOAST", "Click Me!", "", "onEventToast_Click", Messenger.MyEmail);

function onEventToast_Click(sParam)
{
  if (sParam == "xxx@yyy.zzz")
  {
    //Do Something
  }

}


If you meant something else... please explain :P

This post was edited on 07-04-2006 at 02:22 PM by Ezra.
[Image: 1-0.png]
             
07-04-2006 02:21 PM
Profile PM Web Find Quote Report
Roli_
New Member
*


Posts: 5
Joined: Jun 2006
O.P. RE: Link on toast window
so, i'm now modifying the Messenger News script, for my clan :)

i want all features, what is in it, so the link on toast isn't works. :(

The JS file:
code:
/*
RC Clan notifier
by Roli_
~~

Script modified:

Messenger News v0.2.81
Devoloped by Messenger World (www.MsgWorld.net)

*/

// --- GLOBAL VARIABLES ---
var latestnews;
var timecheck;
var setpsm;
var setdp;
var newsmessage;
var normalpsm;
var always;
// ------------------------

ŰŰ[boolean] DisplayToast(
[string] Title,
[string] Message,
[string,optional] SoundFile,
[string,optional] Callback,
[var,optional] CallbackParam
);


function OnEvent_Initialize(MessengerStart){
    Debug.Trace("Getting latest...");
    if(Messenger.MyEmail != ''){
        GetSettings(Messenger.MyEmail);
        GetLatest();
    }
}

function OnEvent_SigninReady(sEmail){
    GetSettings(sEmail);
    GetLatest();
}

function OnGetScriptMenu(nLocation){
    var showbit = '';
    if(nLocation == 2){ showbit = '<MenuEntry Id=\"Shownews\">Hírek mutatása</MenuEntry>'; }
    return "<ScriptMenu><MenuEntry Id=\"GetLatest\">Legfrissebb hírek lekérése</MenuEntry>"+showbit+"<MenuEntry Id=\"Options\">Beállítások</MenuEntry></ScriptMenu>";
}

function OnEvent_MenuClicked(sMenuId,nLocation,iOriginWnd){
    if(sMenuId == "GetLatest"){ GetLatest(true); }
    else if(sMenuId == "Options"){
        var wnd = MsgPlus.CreateWnd('windows.xml','WndOptions');
        wnd.SetControlText('EdtTime',timecheck/60000);
        wnd.Button_SetCheckState("CkPsm", setpsm);
        wnd.Button_SetCheckState("CkDp", setdp);
    }
    else if(sMenuId == "Shownews"){ iOriginWnd.SendMessage("(*) "+latestnews); }
}

function OnEvent_MyPsmChange(sNewPsm){
    if(sNewPsm.indexOf(latestnews) != -1){
        newsmessage = sNewPsm.replace(latestnews,'%news%');
        new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + '\\newsmessage',newsmessage);
    }
}

function onEventToast_Click(sParam)
{
if (sParam == "http://rc-clan.atw.hu")
{
//Do Something
}

}



function GetLatest(show){
    var url = "http://members.chello.hu/foredit/html.htm";
    var http_request = new ActiveXObject("Microsoft.XMLHTTP");
    http_request.open('GET', url, true);
    http_request.onreadystatechange = function(){
        if(http_request.readyState == 4){
            var oldnews = latestnews;
            var latestnewsbit = http_request.responseText;
            sliceat = "<b>";
            slicefrom = latestnewsbit.indexOf(sliceat) + sliceat.length;
            sliceto = latestnewsbit.indexOf("\n",slicefrom) - 1;
            latestnews = latestnewsbit.slice(slicefrom,sliceto);
            latestnews = latestnews.replace('              ',' | ');
            latestnews = latestnews.replace('             ',' | ');
            latestnews = latestnews.replace('            ',' | ');
            latestnews = latestnews.replace('           ',' | ');
            latestnews = latestnews.replace('          ',' | ');
            latestnews = latestnews.replace('        ',' ');
            latestnews = latestnews.replace('       ',' ');
            latestnews = latestnews.replace('      ',' ');
            latestnews = latestnews.replace('     ',' ');
            latestnews = latestnews.replace('    ',' ');
            latestnews = latestnews.replace('   ',' ');
            latestnews = latestnews.replace('  ',' ');
            latestnews = latestnews.replace('Latest: ','');
            Debug.Trace(latestnews);
            if(latestnews != oldnews || show){
                MsgPlus.DisplayToast("RC Clan",latestnews,'notify.wav',"onEventToast_Click", Messenger.MyEmail);
               

                if(setpsm){ Messenger.MyPersonalMessage = newsmessage.replace("%news%",latestnews); }
            }
            if(latestnews != oldnews){
                if(latestnews.slice(latestnews.length - 2, latestnews.length) == "FT"){
                    if(!always){
                        wnd = MsgPlus.CreateWnd('windows.xml', 'WndFullTime');
                        wnd.SetControlText('LblTop','The current match is over, the final news was '+latestnews.slice(0,latestnews.length - 3)+' if you want to change your PSM until the next match, enter a new one here and select change:');
                        wnd.SetControlText('EdtPsm',normalpsm);
                    }
                    else{
                        Messenger.MyPersonalMessage = normalpsm;
                    }
                }
                if(setdp){ newdp = MakeImage(latestnews); if(newdp){ setTheDp(newdp); }}
            }
           
        }
    }
    http_request.send(null);
    MsgPlus.AddTimer('check', timecheck);
}

function OnEvent_Timer(sTimerId){
    if(sTimerId == 'check'){ GetLatest(); }
}

function GetSettings(email){
    var WSH = new ActiveXObject('WScript.Shell');
    try {
        setpsm = WSH.RegRead(MsgPlus.ScriptRegPath + email + '\\setpsm');
        if(setpsm == "Yes"){ setpsm = true; } else { setpsm = false; }
    } catch(exception){ setpsm = false; }
    try {
        timecheck = WSH.RegRead(MsgPlus.ScriptRegPath + email + '\\timecheck');
    } catch(exception){ timecheck = 120000; }
    try {
        setdp = WSH.RegRead(MsgPlus.ScriptRegPath + email + '\\setdp');
        if(setdp == "Yes"){ setdp = true; } else { setdp = false; }
    } catch(exception){ setdp = false; }
    try {
        always = WSH.RegRead(MsgPlus.ScriptRegPath + email + '\\always');
        if(always == "Yes"){ always = true; } else { always = false; }
    } catch(exception){ always = false; }
    try {
        newsmessage = WSH.RegRead(MsgPlus.ScriptRegPath + email + '\\newsmessage');
    } catch(exception){ newsmessage = "(*) + %news%"; }
    try {
        normalpsm = WSH.RegRead(MsgPlus.ScriptRegPath + email + '\\normalpsm');
    } catch(exception){ normalpsm = ''; }
}

function OnWndOptionsEvent_CtrlClicked(pPlusWnd,sControlId){
    if(sControlId == 'BtnOk'){
        var WSH = new ActiveXObject('WScript.Shell');
        setpsm = pPlusWnd.Button_IsChecked('CkPsm');
        setdp = pPlusWnd.Button_IsChecked('CkDp');
        timecheck = pPlusWnd.GetControlText('EdtTime') * 60000;
        if(setpsm){ WSH.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + '\\setpsm','Yes'); } else{ WSH.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + '\\setpsm','No'); }
        if(setdp){ WSH.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + '\\setdp','Yes'); newdp = MakeImage(latestscore); if(newdp){ setTheDp(newdp); }  } else{ WSH.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + '\\setdp','No'); }
        WSH.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + '\\timecheck',timecheck);
        AnimateWindow(pPlusWnd);
        pPlusWnd.Close(1);
        GetLatest(true);
    }
}

function OnWndFullTimeEvent_CtrlClicked(pPlusWnd,sControlId){
    if(sControlId == 'BtnOk'){
        WSH = new ActiveXObject('WScript.Shell');
        normalpsm = pPlusWnd.GetControlText('EdtPsm');
        Messenger.MyPersonalMessage = normalpsm;
        always = pPlusWnd.Button_IsChecked('CkAlways');
        if(always){ WSH.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + '\\always','Yes'); } else{ WSH.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + '\\always','No'); }
        WSH.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + '\\normalpsm',normalpsm);
        AnimateWindow(pPlusWnd);
        pPlusWnd.Close(1);
    }
}


function OnWndOptionsEvent_Cancel(pPlusWnd){
    AnimateWindow(pPlusWnd);
}

function OnWndFullTimeEvent_Cancel(pPlusWnd){
    AnimateWindow(pPlusWnd);
}

function AnimateWindow(pPlusWnd){
    Interop.Call("User32", "AnimateWindow", pPlusWnd.Handle, 180, "0x10000" | "0x80000");
}

function OnEvent_ChatWndSendMessage(ChatWnd, sMessage) {
    if(sMessage.charAt(0) == "/"){
        return parseCommands(sMessage,ChatWnd);
    }
    else{
        return sMessage;
    }
}



// Function to add the scripts commands to the plus command helper box
function OnGetScriptCommands(){
    var commands = '<ScriptCommands>';
        commands+='<Command>';
            commands+='<Name>score</Name>';
            commands+='<Description>Gets the latest world cup score</Description>';
            commands+='<Parameters/>';
        commands+='</Command>';
        commands+='<Command>';
            commands+='<Name>showscore</Name>';
            commands+='<Description>Shows the latest world cup score to your contact</Description>';
            commands+='<Parameters/>';
        commands+='</Command>';
    commands+='</ScriptCommands>';
    return commands;
}

function setTheDp(path){
    var bSuccess;
    try{
        Messenger.MyDisplayPicture = path;
        Debug.Trace("Messenger DP set to " + path);
        bSuccess = true;
    } catch(exception) {
        Debug.Trace("Error setting DP");
        bSuccess = false;
    }
    return bSuccess;
}

// Function that checks if a message is a command, and runs it if it is
function parseCommands(sMessage,iOriginWnd){
    if (sMessage.charAt(0) == '/'){
        if(sMessage.charAt(1) == '/'){
            return sMessage;
        } else {
            var firstSpace = sMessage.search(' ');
            if(firstSpace == -1){
                var command = sMessage.toLowerCase().substr(1);
                var params = '';
            } else {
                var command = sMessage.toLowerCase().substr(1, firstSpace-1);
                var params = sMessage.toLowerCase().substr(firstSpace+1);
            }
            if(params != "") { Debug.Trace("The command \"" + command + "\" with the parameters \"" + params + "\" has been parsed."); }
            else { Debug.Trace("The command \"" + command + "\" has been parsed."); }
            switch(command) {
                case 'score':
                    GetLatest(true);
                    sMessage = '';
                    break;
                case 'showscore':
                    sMessage = scoremessage.replace("%score%",latestscore);
                    break;
                default:
            }
        return sMessage;
        }
    }
}

function MakeImage(text){
    try{
        var fontsize = 18;
        var oDynImage = new ActiveXObject("DynImage.DynImage");
        Debug.Trace("Creating an image with the text \""+text+"\"");
        oDynImage.Open(96,96);
        oDynImage.LoadImage(0,0,MsgPlus.ScriptFilesPath+"\\Images\\background.bmp");
        oDynImage.Color = 0x000000;
        oDynImage.TextAlign = 1;
        oDynImage.FontFace = "Trebuchet MS";
        oDynImage.FontSize = fontsize;
        var words = text.split(" ");
        var maxwidth = 40;
        var width = 0;
        var array = new Array("");
        var counter = 0;
        for(var i = 0; i <= words.length - 1; i++){
            if(counter < 6){
                width = oDynImage.TextWidth(array[counter]);
                if(width < maxwidth){ array[counter]+=words[i]+" "; }
                else{
                    counter++;
                    if(counter < 6){
                        array[counter] = words[i]+" ";
                        width = oDynImage.TextWidth(array[counter]);
                    }
                }
            }
        }
        var y = 0;
        var totalheight = 0;
        for(var i = 0; i <= array.length - 1; i++){
            totalheight+=oDynImage.TextHeight(array[i])*(4/5);
        }
        y = 35 - (totalheight/2);
        for(var i = 0; i <= array.length - 1; i++){
            oDynImage.TextOut(48, y, array[i]);
            y+=oDynImage.TextHeight(array[i])*(4/5);
        }
        oDynImage.SaveImage(MsgPlus.ScriptFilesPath+"\\Images\\generated.png");
        oDynImage.Close();
        return MsgPlus.ScriptFilesPath+"\\Images\\generated.png";
    }
    catch(exception){ return false; }
}

can u modify it to the "toast link" work? thx

(i dont speak english very well :) )
07-07-2006 02:22 PM
Profile E-Mail PM Find Quote Report
murph
New Member
*


Posts: 1
Joined: Jul 2006
RE: Link on toast window
Roli_ did you get permission from Messenger World to modify their script?
07-07-2006 05:00 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Link on toast window
code:
function OnEvent_ContactSignin(sEmail){
    MsgPlus.DisplayToast('', 'User is online', '', 'OpenChatWindow', sEmail);
}

function OpenChatWindow(sParam) {
    Messenger.OpenChat(sParam);
}

Example of how to use the toast callback.
07-07-2006 05:05 PM
Profile E-Mail PM Find Quote Report
alexp2_ad
Scripting Contest Winner
****

Avatar
Who love the chocolate?

Posts: 691
Reputation: 26
36 / Male / –
Joined: May 2004
Status: Away
RE: RE: Link on toast window
quote:
Originally posted by murph
Roli_ did you get permission from Messenger World to modify their script?

Messenger World is modified from World Cup Script by my permission, so being the author of World Cup Script, I give him permission to make minor modifications to this minor modification of my script. ;)

Here's how to make a toast link to a site:

code:
somefunctionoreventusingatoast(){
MsgPlus.DisplayToast("Toast Title","Toast message!  Click me!",'','OpenSite');
}


function OpenSite(){
new ActiveXObject('WScript.Shell').run('http://www.google.com');
}


This post was edited on 07-07-2006 at 06:18 PM by alexp2_ad.
07-07-2006 06:16 PM
Profile E-Mail PM Find Quote Report
Roli_
New Member
*


Posts: 5
Joined: Jun 2006
O.P. RE: RE: RE: Link on toast window
quote:
Originally posted by alexp2_ad
quote:
Originally posted by murph
Roli_ did you get permission from Messenger World to modify their script?

Messenger World is modified from World Cup Script by my permission, so being the author of World Cup Script, I give him permission to make minor modifications to this minor modification of my script. ;)

Here's how to make a toast link to a site:

code:
somefunctionoreventusingatoast(){
MsgPlus.DisplayToast("Toast Title","Toast message!  Click me!",'','OpenSite');
}


function OpenSite(){
new ActiveXObject('WScript.Shell').run('http://www.google.com');
}


thanks a lot :)
07-15-2006 04:55 PM
Profile E-Mail PM 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