Shoutbox

Script does not start, or hook onto Plus! menu - 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: Script does not start, or hook onto Plus! menu (/showthread.php?tid=62904)

Script does not start, or hook onto Plus! menu by absorbation on 07-09-2006 at 01:39 PM

Well my problem is simple really, my script does not appear to start until I edit it and refresh it in the Plus! scripting prefences. It is very odd, but I cannot pin point the problem.

code:
function OnGetScriptMenu(Location)
{
    var ScriptMenu ="<ScriptMenu>";
    ScriptMenu +="<MenuEntry Id=\"Options\">Options</MenuEntry>";
    ScriptMenu +="<Separator/>";
    ScriptMenu +="<MenuEntry Id=\"About\">About Message Enchanter</MenuEntry>";
    ScriptMenu +="</ScriptMenu>";
    return ScriptMenu;
}

Now I am not sure, but it could be something else effecting the hooking, maybe the script failed to start for example, is there soemething I have totally missed to help the script load better? Thanks :).
RE: Script does not start, or hook onto Plus! menu by Paril on 07-09-2006 at 01:42 PM

Well, sometimes, (it happened to me) if a file is huge, it won't load at all. It'll just.. stop, and reload only sometimes.. try splitting some files, if you can.

Other than that, it looks OK..


RE: Script does not start, or hook onto Plus! menu by absorbation on 07-09-2006 at 01:44 PM

I see, well the script is only 129 lines so I don't think it is a problem. Btw, this happens everytime, not just random :P.


RE: Script does not start, or hook onto Plus! menu by Paril on 07-09-2006 at 01:46 PM

Hmm. Something is dead, but I can't pinpoint it... Maybe the .xml (if you're loading one) might be corrupt (IE: not unicode, etc)...


RE: Script does not start, or hook onto Plus! menu by Volv on 07-09-2006 at 01:59 PM

Yes, this problem happens with myself also. My 'OnGetScriptCommands()' returns perfect syntax but fails to show the new command in the commands menu. It only happens with my scripts (even blank scripts) for some reason, and i have had problems with 'OnGetScriptMenu(Location)' also. I tried sticking the following at the beginning of one of my scripts;

code:
function OnEvent_Initialize(MessengerStart)
{
}

function OnEvent_Uninitialize(MessengerExit)
{
}
and it fixed the main plus menu, but not the commands menu (which appears when typing '/'). Note: This only worked with one of my scripts...
RE: Script does not start, or hook onto Plus! menu by absorbation on 07-09-2006 at 02:10 PM

Nope, that did not work for me :(. This never used to happen, I have a feeling some of my other code is effecting it:

code:
//This script was created by absorbation. You may not use any of this code in your work without full permission from me.
//This script was created for free to help you gain a better messenger experience.  I therefore accept no responsiblity for what may happen to your computer, although it is very unlikly to do anything accept change Windows Live Messenger's messages.
//Thanks for using my script and I hope you enjoy it.

var Email = Messenger.MyEmail;
var ScriptName = "Message Enchanter";

function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
var CommandIs = new ActiveXObject('WScript.Shell').RegRead(MsgPlus.ScriptRegPath + Email + "\\command");

if(Message.substring(0,1) != "/") {

    if(CommandIs == "None") {
    return Message;
    }
   
    if(CommandIs == "Bold") {
    return Message.replace(Message, "" + Message + "");
    }
   
    if(CommandIs == "Underline") {
    return Message.replace(Message, "" + Message + "");
    }
   
    if(CommandIs == "Strike") {
    return Message.replace(Message, "" + Message + "");
    }
   
    if(CommandIs == "Caps") {
    return Message.replace(Message, Message.toUpperCase());
    }
   
    if(CommandIs == "CapsAndDots") {
    return Message.replace(Message, Message.substr(0,1).toUpperCase() + Message.substr(1) + '.');
    }
       
    if(CommandIs == "MeCommand") {
    return "/me says: " + Message;
    }
   
    if(CommandIs == "NoIcon") {
    return "/noicon " + Message;
    }
   
    if(CommandIs == "NoFormat") {
    return "/noformat " + Message;
    }
}
}

function OnGetScriptMenu(Location)
{
    var ScriptMenu ="<ScriptMenu>";
    ScriptMenu +="<MenuEntry Id=\"Options\">Options</MenuEntry>";
    ScriptMenu +="<Separator/>";
    ScriptMenu +="<MenuEntry Id=\"About\">About " + ScriptName + "</MenuEntry>";
    ScriptMenu +="</ScriptMenu>";
    return ScriptMenu;
}

function OnEvent_MenuClicked(MenuId)
{
    if(MenuId=="Options"){
        var CommandIs = 'None';
        var CommandIs = new ActiveXObject('WScript.Shell').RegRead(MsgPlus.ScriptRegPath + Email + "\\command");
       
        var Wnd = MsgPlus.CreateWnd("Windows.xml", "Options");
        Wnd.Button_SetCheckState(CommandIs,"True");
    }
   
    if(MenuId=="About"){
        var Wnd = MsgPlus.CreateWnd("Windows.xml", "About");
    }
}

function OnOptionsEvent_CtrlClicked(Wnd, ControlId)
{
    if(ControlId == "BtnClose") {
        MsgPlus.DisplayToast(ScriptName, "Your settings have been saved and your option has been enabled.");
        Wnd.Close(1);
    }
   
    if(ControlId == "None") {
        var CommandIs = "None";
        new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }
   
    if(ControlId == "Bold") {
        var CommandIs = "Bold";
        new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }
   
    if(ControlId == "Underline") {
        var CommandIs = "Underline";
        new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }
   
    if(ControlId == "Strike") {
        var CommandIs = "Caps";
        new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }
       
    if(ControlId == "NoIcon") {
        var CommandIs = "NoIcon";
        new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }
   
    if(ControlId == "NoFormat") {
        var CommandIs = "NoFormat";
        new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }
   
    if(ControlId == "Caps") {
        var CommandIs = "Caps";
        new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }
   
    if(ControlId == "CapsAndDots") {
        var CommandIs = "CapsAndDots";
        new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }
   
    if(ControlId == "MeCommand") {
        var CommandIs = "MeCommand";
        new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }
}

RE: Script does not start, or hook onto Plus! menu by deAd on 07-09-2006 at 03:18 PM

Maybe try changing some global variable names.

code:
var Email = Messenger.MyEmail;
var ScriptName = "Message Enchanter";
Once it wouldn't load the script until I changed the names :S

Also, make sure messenger is signed in when you set Email to Messenger.MyEmail:^)...but not sure
RE: Script does not start, or hook onto Plus! menu by absorbation on 07-09-2006 at 04:23 PM

quote:
Originally posted by deAd
Also, make sure messenger is signed in when you set Email to Messenger.MyEmail(Smilie)...but not sure


That makes 100% sence, I use the Email varible alot of times, it explains why it breaks. Let me just try that ...
RE: Script does not start, or hook onto Plus! menu by Stigmata on 07-09-2006 at 05:03 PM

does the debug throw an error by any chance?


RE: Script does not start, or hook onto Plus! menu by AberNStein on 07-10-2006 at 01:39 AM

why not just put the menu and commands in ScriptInfo.xml?


RE: Script does not start, or hook onto Plus! menu by CookieRevised on 07-10-2006 at 01:44 AM

@absorbation: As dead already mentionned, note that scripts can be started even before you are signed in. At that time certain objects are not yet available (eg: Messenger.MyEmail)... In other words, be careful in using global variables like that. Assign the actual values in the Initialize() event instead or even in the SinginReady() event.


RE: Script does not start, or hook onto Plus! menu by Volv on 07-10-2006 at 02:14 PM

Well considering I only have about 6 variables declared outside function and all of those declarations are either setting the var to 0 or "" :(


RE: Script does not start, or hook onto Plus! menu by deAd on 07-10-2006 at 02:23 PM

Try renaming them :P once the script wouldn't load because i had variables named "ENCRYPT" and "DECRYPT", and it worked after i renamed them :S