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:
Yustme
Junior Member
**


Posts: 85
41 / – / –
Joined: Aug 2005
O.P. create a button
Hi,

How do i create a button in the msg plus icon for scripts?

I've done some searches here and it's kinda confusing. I see xml but also menu's made in the code itself.

Can somebody provide me a peace of code that creates a button?

Just to create one, not how to catch events and clicks etc. I'll figure that one out myself.

Thanks in advance!
02-26-2010 11:34 AM
Profile PM Find Quote Report
djdannyp
Elite Member
*****

Avatar
Danny <3 Sarah

Posts: 3546
Reputation: 31
38 / Male / Flag
Joined: Mar 2006
RE: create a button
You mean a menu under the scripts icon?

For a simple example, check the Facebook Status script linked in my signature, it's a very short script with built in, functioning menus.

Thanks
[Image: 1ftt0hpk-signature.png]
AutoStatus Script || Facebook Status Script
5425 days, 18 hours, 21 minutes, 25 seconds ago
02-26-2010 12:18 PM
Profile E-Mail PM Find Quote Report
billyy
Full Member
***

Avatar

Posts: 103
Reputation: 1
37 / Male / Flag
Joined: Feb 2010
Status: Away
RE: create a button
Ahh in the scripts menu, well you could use:

jscript code:

function OnGetScriptMenu(Location)
{
     var scriptmenu = "<ScriptMenu>";
     scriptmenu += "<MenuEntry Id=\"[ID]\">[Text]</MenuEntry>";
     scriptmenu += "<MenuEntry Id=\"[ID2]\">[Text2]</MenuEntry>";
     scriptmenu += "<Separator/>";
     scriptmenu += "<MenuEntry Id=\"[ID3]\">[Text3]</MenuEntry>";
     scriptmenu += "</ScriptMenu>";
     //a blackslash infront of a " is invisable in the outcome but will forecome " ending the string.
}

fill in the ID it should return when clicked at [ID] and the text it should show at [Text].
Ofcourse removing the square brackets.
also you can use <Separator/> between Menu Entries to add a line between those entries.

The event called when the menu is clicked will be:
jscript code:
function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd)
{
}

You could fill in like:
jscript code:
function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd)
{
     switch (MenuItemId)
     {
          case "[ID]":
               MsgPlus.DisplayToast("Title", "That tickles!");
          break;
     }
}


Now we have a complete working script!
Ofcourse what it does IS pointless and it's NOT gunna turn you in to an ugly rat. Alltough if it does you should definately PM me O_o

jscript code:
/*****************************\
|           Warning!          |
|    Reading the following    |
|    script will turn you     |
|    in to a big ugly rat!    |
\*****************************/

function OnGetScriptMenu(Location)
{
     var scriptmenu = "<ScriptMenu>";
     scriptmenu += "<MenuEntry Id=\"[ID]\">[Text]</MenuEntry>";
     scriptmenu += "<MenuEntry Id=\"[ID2]\">[Text2]</MenuEntry>";
     scriptmenu += "<Separator/>";
     scriptmenu += "<MenuEntry Id=\"[ID3]\">[Text3]</MenuEntry>";
     scriptmenu += "</ScriptMenu>";
}

function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd)
{
     switch (MenuItemId)
     {
          case "[ID]":
               MsgPlus.DisplayToast("Title", "That tickles!");
          break;
          case "[ID2]":
               MsgPlus.DisplayToast("Title", "You just had to try 2 huh?");
          break;
          case "[ID3]":
               MsgPlus.DisplayToast("Title", "Ok jokes over >:l");
          break;
     }
}

This is just simple, you could ofcourse make it check if you have clicked ID1 before and THAN give 2 and so on, but that is not what this example is about. (trying to keep it simple :))

And you could use xml to make like a nice preference window.
For that you could use Interface Writer, it is easy to make a pretty nice interface.

edit:
quote:
Originally posted by Yustme
Just to create one, not how to catch events and clicks etc. I'll figure that one out myself.
Couldn't help myself :(

Edit2:
Humz, changed the first part, adding them one by one just looks so cute :P
Alltough again mattys script is much more complicated and probably more helpfull...

This post was edited on 02-26-2010 at 06:42 PM by billyy.
I'm new at this, so don't expect me to be usefull any
time soon. But if i behaved you could rep me :P
02-26-2010 04:15 PM
Profile E-Mail PM Find Quote Report
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
Yustme
Junior Member
**


Posts: 85
41 / – / –
Joined: Aug 2005
O.P. RE: create a button

Hi guys,

Thank you very much! :)
02-26-2010 06:58 PM
Profile PM Find Quote Report
Yustme
Junior Member
**


Posts: 85
41 / – / –
Joined: Aug 2005
O.P. RE: create a button

I got a small question. The items in 'MenuEntry' are being displayed on the right side.

Can that be changed to the left side?

So i'm talking about the submenu entries.
02-26-2010 08:18 PM
Profile PM Find Quote Report
djdannyp
Elite Member
*****

Avatar
Danny <3 Sarah

Posts: 3546
Reputation: 31
38 / Male / Flag
Joined: Mar 2006
RE: create a button
quote:
Originally posted by Yustme
I got a small question. The items in 'MenuEntry' are being displayed on the right side.

Can that be changed to the left side?

So i'm talking about the submenu entries.

No, as menus traditionally flow from left to right
[Image: 1ftt0hpk-signature.png]
AutoStatus Script || Facebook Status Script
5425 days, 18 hours, 21 minutes, 25 seconds ago
02-26-2010 09:28 PM
Profile E-Mail PM Find Quote Report
« 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