What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » How to make a menu and commands?

Pages: (2): « First [ 1 ] 2 » Last »
How to make a menu and commands?
Author: Message:
Dr Nick
Junior Member
**

Avatar
Firefox > IE

Posts: 59
Reputation: 1
31 / Male / Flag
Joined: Dec 2008
O.P. How to make a menu and commands?
Hi, I have developed a script that rotates my PM, and changes it depending on what my status is.

I wish to develop a menu (in the scripts menu) that will allow me to enable/ disable this script (I have made a variable that will allow me to do this, but I have to be able to change this variable with a menu click [this is only if there is no easier way to disable the script]).

I also want to make a command that will call a function to force the PM to rotate if I wish to make it rotate faster than the normal speed.

How would I do this?

Thanks for your help!
Nick
<?
while(!success) { $try++; }
?>
-----------------
Windows 7 Ultimate (6.1.7000)
Windows Live Messenger 14.0.0206
Messenger Plus! Live 4.81.0.358
02-11-2009 02:51 AM
Profile PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: How to make a menu and commands?
Menu functions:
Javascript code:
function OnGetScriptMenu(nLocation){
    var oMenu = new ScriptMenu();
       
    with (oMenu) {
        AddSubMenu('My Menu'));
            AddItem('/mycommand1', 'My Command without parameter');
            AddItem('/mycommand1 5', 'My command with parameter');
            AddSeperator();
            AddItem('', 'Disabled item', false);
        CloseSubMenu();
    }
    return oMenu.ExportMenu();
}
 
function OnEvent_MenuClicked(sMenuId, nLocation, oChatWnd){
    OnEvent_ChatWndSendMessage(oChatWnd, sMenuId);
}


Command functions:
Javascript code:
function OnGetScriptCommands(){
    var oCommand = new Commands();
    with (oCommand) {
        AddCommand('mycommand1', 'My command without parameter');
        AddCommand('mycommand1', 'My command with parameter', 5);
    }
    return oCommand.ExportCommands();  
}
 
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
    if (/^\/([^\s\/]+)\s*([\s\S]*)$/.exec(sMenuId) !== null) {
        var _command = RegExp.$1.toLowerCase();
        var _param = RegExp.$2;
        switch (_command) {
            case 'mycommand':
                if ( _param !== '' ) {
                    /*
                        Do stuff here
                    */

                } else {
                    /*
                        Do stuff here
                    */

                }
                break;
        }
    }
}


.zip File Attachment: script classes.zip (1022 bytes)
This file has been downloaded 72 time(s).

This post was edited on 02-11-2009 at 03:18 PM by matty.
02-11-2009 01:46 PM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: How to make a menu and commands?
quote:
Originally posted by matty
Javascript code:
function OnGetScriptCommands(){
    var oCommand = new Commands();
    with (oCommand) {
        oCommand.AddCommand('mycommand1', 'My command without parameter');
        oCommand.AddCommand('mycommand1', 'My command with parameter', 5);
    }
    return oCommand.ExportCommands();  
}




Shouldn't that be:

Javascript code:
function OnGetScriptCommands(){
    var oCommand = new Commands();
    with (oCommand) {
        AddCommand('mycommand1', 'My command without parameter');
        AddCommand('mycommand1', 'My command with parameter', 5);
    }
    return oCommand.ExportCommands();  
}


:p

This post was edited on 02-11-2009 at 02:36 PM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
02-11-2009 02:35 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: How to make a menu and commands?
quote:
Originally posted by Spunky
quote:
Originally posted by matty
Javascript code:
function OnGetScriptCommands(){
    var oCommand = new Commands();
    with (oCommand) {
        oCommand.AddCommand('mycommand1', 'My command without parameter');
        oCommand.AddCommand('mycommand1', 'My command with parameter', 5);
    }
    return oCommand.ExportCommands();  
}




Shouldn't that be:

Javascript code:
function OnGetScriptCommands(){
    var oCommand = new Commands();
    with (oCommand) {
        AddCommand('mycommand1', 'My command without parameter');
        AddCommand('mycommand1', 'My command with parameter', 5);
    }
    return oCommand.ExportCommands();  
}


:p
Yes you are correct!
02-11-2009 03:18 PM
Profile E-Mail PM Find Quote Report
Dr Nick
Junior Member
**

Avatar
Firefox > IE

Posts: 59
Reputation: 1
31 / Male / Flag
Joined: Dec 2008
O.P. RE: How to make a menu and commands?
Thanks, But I have tried this and when I try to start the script after changing it, I am told that I dont have the permissions to run it, or it is defective. Am I doing something wring here?

Thanks
Nick
Now it works (I removed a ")" in the menu bit) but i get the following error, and the commands / menu dont work:
Error: Object expected (code: -2146823281)
       File: __commands.js. Line: 15.
Function OnGetScriptCommands returned an error. Code: -2147352567
And when I try to send a message
Function called: OnEvent_ChatWndSendMessage
Error: 'sMenuId' is undefined (code: -2146823279)
       File: Status Checker.js. Line: 145.
Function OnEvent_ChatWndSendMessage returned an error. Code: -2147352567
<?
while(!success) { $try++; }
?>
-----------------
Windows 7 Ultimate (6.1.7000)
Windows Live Messenger 14.0.0206
Messenger Plus! Live 4.81.0.358
02-12-2009 06:30 AM
Profile PM Web Find Quote Report
djdannyp
Elite Member
*****

Avatar
Danny <3 Sarah

Posts: 3546
Reputation: 31
37 / Male / Flag
Joined: Mar 2006
RE: How to make a menu and commands?
post your entire code using [code=xml][/code] tags around it so that it get highlighted properly, as matty and Spunky did
[Image: 1ftt0hpk-signature.png]
AutoStatus Script || Facebook Status Script
5223 days, 18 hours, 27 minutes, 43 seconds ago
02-12-2009 10:50 AM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: How to make a menu and commands?
Wow I guess I should look at my coding before posting it...

Ok first things first in __commands.js we need to edit a line
Javascript code:
(typeof sParameter === 'undefined' ? '' : '<Parameters>&lt;'+LoadString('CommandDelay')+'&gt;</Parameters>')+

Change to:
Javascript code:
(typeof sParameter === 'undefined' ? '' : '<Parameters>&lt;'+sParameter+'&gt;</Parameters>')+

Glad I found this because the code is used in Screenshot Sender as well! Oopsies!

And these functions needs to be changed:
Javascript code:
function OnGetScriptCommands(){
    var oCommand = new Commands();
    with (oCommand) {
        AddCommand('mycommand1', 'My command without parameter');
        AddCommand('mycommand1', 'My command with parameter', 'Enter a parameter');    }
    return oCommand.ExportCommands();  
}
 
 
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
    if (/^\/([^\s\/]+)\s*([\s\S]*)$/.exec(sMessage) !== null) {        var _command = RegExp.$1.toLowerCase();
        var _param = RegExp.$2;
        switch (_command) {
            case 'mycommand':
                if ( _param !== '' ) {
                    /*
                        Do stuff here
                    */
                } else {
                    /*
                        Do stuff here
                    */
                }
                break;
        }
    }
}


This post was edited on 02-12-2009 at 01:58 PM by matty.
02-12-2009 01:56 PM
Profile E-Mail PM Find Quote Report
Dr Nick
Junior Member
**

Avatar
Firefox > IE

Posts: 59
Reputation: 1
31 / Male / Flag
Joined: Dec 2008
O.P. RE: How to make a menu and commands?
Better, but i renamed the commands, and edited the menu etc, but nothing works.

The commands show up in the command list, but when i enter them, it says the command was not recognised...

Also, when the button in the menu is clicked, the function is not called...

Here is my code...
The code for the menu and command is down the very bottom
XML code:
var originalPSM;
var idleSeconds;
var isIdle;
var isBusy;
var PSMnumber;
var seconds = 60;
 
function OnEvent_Initialize(MessengerStart)
{
    idleSeconds = 0;
    isIdle = false;
    isBusy = false;
    MsgPlus.AddTimer('rotate', seconds * 1000);
}
 
function OnEvent_Uninitialize(MessengerExit)
{
}
 
function updateMessage() {
        if(PSMnumber==1) {
            originalPSM = "Growing old is mandatory, growing up is optional";
            PSMnumber=2;
        } else {
            originalPSM = "There are only two ways to live your life. One is as though nothing is a miracle. The other is as if everything is.";
            PSMnumber=1;
        }
        Messenger.MyPersonalMessage = originalPSM;
}
 
function OnEvent_MyStatusChange(NewStatus)
{
    if( NewStatus == 7 || NewStatus == 6 )
    {
        Messenger.MyPersonalMessage = "Text/ ring me and I'll be back ASAP! 0hrs:0mins:0secs";
        MsgPlus.AddTimer( "incIdle", 1000 );
        MsgPlus.AddTimer( "updateDisplay", 6000 );
        isIdle = true;
        isBusy = false;
    } else if(NewStatus == 4) {
        Messenger.MyPersonalMessage = "Text me! I'm in a full screen app and mssngr alerts are off! :)";
        isBusy = true;
        isIdle = false;
        idleSeconds = 0;
    }
    else
    {
        isIdle = false;
        isBusy = false;
        idleSeconds = 0;
        updateMessage();
        MsgPlus.AddTimer('rotate', seconds * 1000);
    }
}
 
function OnEvent_Timer(sTimerId)
{
    if( isIdle == false && isBusy == false)
    {
        updateMessage();
        MsgPlus.AddTimer('rotate', seconds * 1000);
        return 0;
    }
    else if( sTimerId == "incIdle" )
    {
        if(isIdle==true) {
            idleSeconds ++;
            MsgPlus.AddTimer( "incIdle", 1000 );
        }
    }
    else if( sTimerId == "updateDisplay" )
    {
        if(isIdle==true) {
            var cIdleSeconds = idleSeconds;
            var idleHours = 0;
            var idleMinutes = 0;
           
            while( cIdleSeconds > 59 )
            {
                cIdleSeconds -= 60;
                idleMinutes ++;
            }
           
            while( idleMinutes > 59 )
            {
                idleMinutes -= 60;
                idleHours ++;
            }
   
            Messenger.MyPersonalMessage = "Text/ ring me and I'll be back ASAP! "+idleHours+"hrs:"+idleMinutes+"mins:"+cIdleSeconds+"secs";
            MsgPlus.AddTimer( "updateDisplay", 6000 );
        }
    }
}
 
function OnGetScriptCommands(){
    var oCommand = new Commands();
    with (oCommand) {
        AddCommand('PMrotate', 'Rotate your Personal Message');    }
    return oCommand.ExportCommands();  
}
 
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
    if (/^\/([^\s\/]+)\s*([\s\S]*)$/.exec(sMessage) !== null) {        var _command = RegExp.$1.toLowerCase();
        var _param = RegExp.$2;
        switch (_command) {
            case 'PMrotate':
                if ( _param !== '' ) {
                    updateDisplay();
                } else {
                    updateDisplay();
                }
                break;
        }
    }
}
 
function OnGetScriptMenu(nLocation){
    var oMenu = new ScriptMenu();
       
    with (oMenu) {
        AddSubMenu('My Menu');
            AddItem('/PMrotate', 'Roate your Personal Message');
        CloseSubMenu();
        AddItem('/PMrotate', 'Roate your Personal Message');
    }
    return oMenu.ExportMenu();
}
 
function OnEvent_MenuClicked(sMenuId, nLocation, oChatWnd){
    OnEvent_ChatWndSendMessage(oChatWnd, sMenuId);
}

I also have the two files from Matty
<?
while(!success) { $try++; }
?>
-----------------
Windows 7 Ultimate (6.1.7000)
Windows Live Messenger 14.0.0206
Messenger Plus! Live 4.81.0.358
02-13-2009 06:55 AM
Profile PM Web Find Quote Report
Dr Nick
Junior Member
**

Avatar
Firefox > IE

Posts: 59
Reputation: 1
31 / Male / Flag
Joined: Dec 2008
O.P. RE: How to make a menu and commands?
I also plan on adding a command such as:
/addPM "This is my PM"
So the Pm's will be stored in an array or something, and you can add to it with a command.

Any ideas on how I could do this?

Thanks for all the help!
Nick
<?
while(!success) { $try++; }
?>
-----------------
Windows 7 Ultimate (6.1.7000)
Windows Live Messenger 14.0.0206
Messenger Plus! Live 4.81.0.358
02-13-2009 06:58 AM
Profile PM Web Find Quote Report
Th3rmal
Veteran Member
*****

Peek-a-boo! I see you!!

Posts: 1226
Reputation: 26
32 / Male / Flag
Joined: Aug 2005
RE: How to make a menu and commands?
quote:
Originally posted by Dr Nick
I also plan on adding a command such as:
/addPM "This is my PM"
So the Pm's will be stored in an array or something, and you can add to it with a command.

Any ideas on how I could do this?

Thanks for all the help!
Nick
I dont script, but IIRC the solution to this kind of thing is usually to store it in a text file, then get the script to read it off the text file. Although i could be horribly wrong :P
You have the intellect comparable to that of a rock. Be proud.
02-13-2009 07:06 AM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« 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