What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » create a button

create a button
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: create a button
I use this class
js code:
/*
* -----
* Screenshot Sender - __script_menu.js
* -----
* Menu creator for Screenshot Sender
* -----
*/

var ScriptMenu = function () {
    this.ScriptMenu = '';
}

ScriptMenu.prototype = {
    /*
        Name:     AddItem
        Purpose:    Add an item to the script menu
        Parameters:    sId - The id of the menu item
                    sLabel - The label of menu item
                    bEnabled - If the menu item will be enabled
        Return:    None
    */
    "AddItem" : function (sId, sLabel, bEnabled) {
        if (typeof bEnabled === 'undefined') bEnabled = true;
        this.ScriptMenu += '<MenuEntry Id=\''+sId+'\' Enabled=\''+bEnabled+'\'>'+sLabel+'</MenuEntry>';
    },
   
    /*
        Name:     AddSubMenu
        Purpose:    Add a submenu to the menu
        Parameters:    sLabel - Submenu label
                    bEnabled - If the submenu is enabled or not
        Return:    None
    */
    "AddSubMenu" : function (sLabel, bEnabled) {
        if (typeof bEnabled === 'undefined') bEnabled = true;
        this.ScriptMenu += '<SubMenu Label=\''+sLabel+'\' Enabled=\''+bEnabled+'\'>';
    },
   
    /*
        Name:     CloseSubMenu
        Purpose:    Close the currently open submenu
        Parameters:    None
        Return:    None
    */
    "CloseSubMenu" : function () {
        this.ScriptMenu += '</SubMenu>';
    },
   
    /*
        Name:     AddSeperator
        Purpose:    Creates a seperator in the menu
        Parameters:    None
        Return:    None
    */
    "AddSeperator" : function () {
        this.ScriptMenu += '<Separator />';
    },
   
    /*
        Name:     ExportMenu
        Purpose:    Export the xml formed menu
        Parameters:    None
        Return:    The menu in xml form
    */
    "ExportMenu" : function () {
        return '<ScriptMenu>'+this.ScriptMenu+'</ScriptMenu>';
    }
       
}

Which in turn is used like this:
js code:
function OnGetScriptMenu(nLocation) {
    var bEnabled = (Messenger.MyStatus > STATUS_INVISIBLE);
    var bSignedIn = (Messenger.MyStatus >= STATUS_INVISIBLE);
   
    var oMenu = new ScriptMenu();
       
    with (oMenu) {
        if (nLocation === MENULOC_CHATWND ) {
            AddSubMenu(_lang.text['MenuActiveWindow']);
                AddItem('/ssactive', _lang.text['SubMenuSendActiveWindow'], bEnabled);
                AddItem('/sssactive', _lang.text['SubMenuSaveActiveWindow'], bSignedIn);
                AddSeperator();
                AddItem('/ssactive ' + objPreferences['tTimeDelay'], _lang.text['SubMenuSendActiveWindowDelay'], bEnabled);
                AddItem('/sssactive ' + objPreferences['tTimeDelay'], _lang.text['SubMenuSaveActiveWindowDelay'], bSignedIn);
            CloseSubMenu();
            AddSubMenu(_lang.text['MenuFullscreen']);
                AddItem('/ssfullscreen', _lang.text['SubMenuSendFullscreen'], bEnabled);
                AddItem('/sssfullscreen', _lang.text['SubMenuSaveFullscreen'], bSignedIn);
                AddSeperator();
                AddItem('/ssfullscreen ' + objPreferences['tTimeDelay'], _lang.text['SubMenuSendFullscreenDelay'], bEnabled);
                AddItem('/sssfullscreen ' + objPreferences['tTimeDelay'], _lang.text['SubMenuSaveFullscreenDelay'], bSignedIn);
            CloseSubMenu();
            AddSubMenu(_lang.text['MenuSelectArea']);
                AddItem('/ssselect', _lang.text['SubMenuSendSelectArea'], bEnabled);
                AddItem('/sssselect', _lang.text['SubMenuSaveSelectArea'], bSignedIn);
                AddSeperator();
                AddItem('/ssselect ' + objPreferences['tTimeDelay'], _lang.text['SubMenuSendSelectAreaDelay'], bEnabled);
                AddItem('/sssselect ' + objPreferences['tTimeDelay'], _lang.text['SubMenuSaveSelectAreaDelay'], bSignedIn);
            CloseSubMenu();
            AddSubMenu(_lang.text['MenuClipboard']);
                AddItem('/ssclipboard', _lang.text['SubMenuSendClipboard'], bEnabled);
                AddItem('/sssclipboard', _lang.text['SubMenuSaveClipboard'], bSignedIn);
            CloseSubMenu();
            AddSubMenu(_lang.text['MenuPointClickCapture']);
                AddItem('/sspcc', _lang.text['SubMenuSendPointClickCapture'], bEnabled);
                AddItem('/ssspcc', _lang.text['SubMenuSavePointClickCapture'], bSignedIn);
            CloseSubMenu();
            if (SelectedMonitor(0, 0, 0, 0, true) > 1) {
                AddSubMenu(_lang.text['MenuSelectedMonitor']);
                    AddItem('/ssmonitor', _lang.text['SubMenuSendSelectedMonitor'], bEnabled);
                    AddItem('/sssmonitor', _lang.text['SubMenuSaveSelectedMonitor'], bSignedIn);
                CloseSubMenu();
            }
            AddSubMenu(_lang.text['MenuByWindowTitle']);
                AddItem('/sswindow', _lang.text['SubMenuSendWindowByTitle'], bEnabled);
                AddItem('/ssswindow', _lang.text['SubMenuSaveWindowByTitle'], bSignedIn);
            CloseSubMenu();
            AddSeperator();
        }
       
        if (IsTimerActive == true) {
            AddItem('CancelTimer', _lang.text['MenuCancelTimer'], bEnabled);
            AddSeperator();
        }
       
        AddItem('OpenDirectory', _lang.text['MenuOpenDirectory'], bSignedIn);
        AddItem('ScreenshotViewer', _lang.text['MenuScreenshotViewer'], bSignedIn);
       
        if (nLocation === MENULOC_CHATWND && SessionImages.Images.length > 0) {
            AddItem('RecentImages', _lang.text['MenuRecentImages'], bEnabled);
            AddSeperator();
        }
       
        AddItem('Preferences', _lang.text['MenuPreferences'], bSignedIn)
        AddSeperator();
        AddItem('About', _lang.text['MenuAbout'], bSignedIn)
    }
   
    return oMenu.ExportMenu();
}

This post was edited on 02-26-2010 at 05:57 PM by matty.
02-26-2010 05:55 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
create a button - by Yustme on 02-26-2010 at 11:34 AM
RE: create a button - by djdannyp on 02-26-2010 at 12:18 PM
RE: create a button - by billyy on 02-26-2010 at 04:15 PM
RE: create a button - by matty on 02-26-2010 at 05:55 PM
RE: create a button - by Yustme on 02-26-2010 at 06:58 PM
RE: create a button - by Yustme on 02-26-2010 at 08:18 PM
RE: create a button - by djdannyp on 02-26-2010 at 09:28 PM


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