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?

How to make a menu and commands?
Author: Message:
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:
js 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:
js 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 79 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
« Next Oldest Return to Top Next Newest »

Messages In This Thread
How to make a menu and commands? - by Dr Nick on 02-11-2009 at 02:51 AM
RE: How to make a menu and commands? - by matty on 02-11-2009 at 01:46 PM
RE: How to make a menu and commands? - by Spunky on 02-11-2009 at 02:35 PM
RE: How to make a menu and commands? - by matty on 02-11-2009 at 03:18 PM
RE: How to make a menu and commands? - by Dr Nick on 02-12-2009 at 06:30 AM
RE: How to make a menu and commands? - by djdannyp on 02-12-2009 at 10:50 AM
RE: How to make a menu and commands? - by matty on 02-12-2009 at 01:56 PM
RE: How to make a menu and commands? - by Dr Nick on 02-13-2009 at 06:55 AM
RE: How to make a menu and commands? - by Dr Nick on 02-13-2009 at 06:58 AM
RE: How to make a menu and commands? - by Th3rmal on 02-13-2009 at 07:06 AM
RE: How to make a menu and commands? - by matty on 02-13-2009 at 07:08 AM
RE: How to make a menu and commands? - by Dr Nick on 02-13-2009 at 08:08 AM
RE: How to make a menu and commands? - by matty on 02-13-2009 at 01:45 PM
RE: How to make a menu and commands? - by Dr Nick on 02-13-2009 at 11:41 PM
RE: How to make a menu and commands? - by matty on 02-14-2009 at 04:23 AM
RE: How to make a menu and commands? - by Dr Nick on 02-14-2009 at 08:02 AM


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