Link on toast window - 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: Link on toast window (/showthread.php?tid=62513)
Link on toast window by Roli_ on 07-04-2006 at 02:19 PM
how to put a link on a toast window?
RE: Link on toast window by Ezra on 07-04-2006 at 02:21 PM
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
RE: Link on toast window by Roli_ on 07-07-2006 at 02:22 PM
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 )
RE: Link on toast window by murph on 07-07-2006 at 05:00 PM
Roli_ did you get permission from Messenger World to modify their script?
RE: Link on toast window by matty on 07-07-2006 at 05:05 PM
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.
RE: RE: Link on toast window by alexp2_ad on 07-07-2006 at 06:16 PM
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');
}
RE: RE: RE: Link on toast window by Roli_ on 07-15-2006 at 04:55 PM
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
|