create a button - 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: create a button (/showthread.php?tid=93965)
create a button by Yustme on 02-26-2010 at 11:34 AM
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!
RE: create a button by djdannyp on 02-26-2010 at 12:18 PM
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
RE: create a button by billyy on 02-26-2010 at 04:15 PM
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
Alltough again mattys script is much more complicated and probably more helpfull...
RE: create a button by matty on 02-26-2010 at 05:55 PM
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();
}
RE: create a button by Yustme on 02-26-2010 at 06:58 PM
Hi guys,
Thank you very much!
RE: create a button by Yustme on 02-26-2010 at 08:18 PM
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.
RE: create a button by djdannyp on 02-26-2010 at 09:28 PM
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
|