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

a GUI for this
Author: Message:
Barathrum
Junior Member
**

Avatar
.......................

Posts: 42
30 / Male / Flag
Joined: Nov 2009
O.P. a GUI for this
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
  return "< " + Message + " >"
}


I would like someone to make me a GUI so you can quicky enable or disable it.


Thank you.

This post was edited on 06-20-2010 at 08:25 AM by Barathrum.
06-20-2010 08:24 AM
Profile E-Mail PM Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: a GUI for this
Just make a script menu toggle button? I would do it but, you should get some experience by looking it up in the documentation or in other peoples scripts (NOTE: if you do use other peoples scripts, don't just copy and paste and wonder why its not working... have a look at what they do and recode it to make it your own style).

If you still need help after you have tried doing this, post your code back up here and we will help you out [=
06-20-2010 08:58 AM
Profile PM Find Quote Report
Barathrum
Junior Member
**

Avatar
.......................

Posts: 42
30 / Male / Flag
Joined: Nov 2009
O.P. RE: a GUI for this
I have no idea about scripting or it's documentation, I hardly even put that script together.

This post was edited on 06-20-2010 at 09:13 AM by Barathrum.
06-20-2010 09:11 AM
Profile E-Mail PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
RE: a GUI for this
I would have linked to the scripting documentation page, but the site seems to be down for maintenance.

quote:
Source: Scripting Documentation > Events Reference > Messenger Plus! Events > OnGetScriptMenu


The OnGetScriptMenu event is fired when some of the Messenger Plus! menus are displayed. It allows scripts to return their own menu to be added to Messenger Plus!'s one.


Syntax
Javascript code:
[string] OnGetScriptMenu(
    [enum] Location
);



Parameters

Location
[enum] A number specifying the location of the menu that triggered the event. You can use this parameter to display a different menu depending on what the current user is currently doing.  It can be one of the following values:
code:
MENULOC_CONTACTLIST (1)   Contact List
MENULOC_CHATWND (2)       Messenger Chat Window
MENULOC_MOBILEWND (3)     Mobile Device Chat Window


Return Value

An XML data string defining the script's menu. If no menu is required, return an empty string. For more information about the way to define the menu's data, see the ScriptInfo's schema documentation.


Remarks

The script's menu can be defined statically in the ScriptInfo.xml file or returned by this function is its content needs changes at runtime. If a menu is returned by this handler, it gets priority over the menu defined in ScriptInfo.xml.

If an item of the script's menu is selected by the current user, an OnEvent_MenuClicked is fired.

Messenger Plus! 4.23 and earlier: enumeration names are not available, numbers must be used instead.

Messenger Plus! 4.50 and earlier: MENULOC_MOBILEWND is not supported.


Example

Event handler generating a simple menu for the script:
Javascript code:
function OnGetScriptMenu(Location)
{
    var ScriptMenu = "<ScriptMenu>";
    ScriptMenu    +=     "<MenuEntry Id=\"MnuFeat1\">Feature 1</MenuEntry>";
    ScriptMenu    +=     "<MenuEntry Id=\"MnuFeat2\">Feature 2</MenuEntry>";
    ScriptMenu    +=     "<Separator/>";
    ScriptMenu    +=     "<MenuEntry Id=\"MnuAbout\">About...</MenuEntry>";
    ScriptMenu    += "</ScriptMenu>";
   
    return ScriptMenu;
}



This post was edited on 06-20-2010 at 10:12 AM by whiz.
06-20-2010 10:11 AM
Profile E-Mail PM Find Quote Report
Barathrum
Junior Member
**

Avatar
.......................

Posts: 42
30 / Male / Flag
Joined: Nov 2009
O.P. RE: a GUI for this
And now I'm just suposed to understand anything of this?
06-20-2010 12:06 PM
Profile E-Mail PM Find Quote Report
Menthix
forum admin
*******

Avatar

Posts: 5537
Reputation: 102
40 / Male / Flag
Joined: Mar 2002
RE: a GUI for this
quote:
Originally posted by Barathrum
And now I'm just suposed to understand anything of this?
Preferably :)
Finish the problem
Menthix.net | Contact Me
06-20-2010 12:27 PM
Profile E-Mail PM Web Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
RE: a GUI for this
So far, you have your ChatWnd function:
Javascript code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    return "< " + Message + " >";
}


Firstly, we need a variable to store whether the script is enabled or not.
Javascript code:
var Enabled = false; // disabled by default

This should be global (outside of any function), so put it at the top.

We then need to modify the message function so it only occurs if the variable is true (enabled).
Javascript code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    if (Enabled)
    {
        return "< " + Message + " >";
    }
}


The script menu is written in XML, and Plus! calls the event OnGetScriptMenu() when it is opened.
Javascript code:
function OnGetScriptMenu()
{
    // return the menu
}


The script menu should take this format:
XML code:
<ScriptMenu>
    <MenuEntry Id="ItemID1">Displayed name...</MenuEntry>
    <MenuEntry Id="ItemID2" Enabled="false">Disabled item...</MenuEntry>
    <Separator/>
    <SubMenu Label="I'm a sub-menu!">
        <MenuEntry Id="ItemID3">Another item...</MenuEntry>
    </SubMenu>
</ScriptMenu>


To make the menu, we return this as a string.  Your menu will need one option, to enable or disable the script.  We can change the text based on whether the script is enabled or not.
Javascript code:
function OnGetScriptMenu()
{
    var ScriptMenu = "<ScriptMenu>";
    if (Enabled)
    {
        ScriptMenu += "<MenuEntry Id=\"Toggle\">Disable</MenuEntry>";
    }
    else
    {
        ScriptMenu += "<MenuEntry Id=\"Toggle\">Enable</MenuEntry>";
        // note the use of the same ID
    }
    ScriptMenu += "</ScriptMenu>";
    return ScriptMenu;
}


To check and process menu clicks, use the OnEvent_MenuClicked() function:
Javascript code:
function OnEvent_MenuClicked(MenuEntryId, Location, OriginWnd)
{
    if (MenuEntryId === "Toggle")
    {
        Enabled = !Enabled; // invert the value
    }
}




And so, the finished script:
Javascript code:
var Enabled = false;
 
function OnGetScriptMenu()
{
    var ScriptMenu = "<ScriptMenu>";
    if (Enabled)
    {
        ScriptMenu += "<MenuEntry Id=\"Toggle\">Disable</MenuEntry>";
    }
    else
    {
        ScriptMenu += "<MenuEntry Id=\"Toggle\">Enable</MenuEntry>";
    }
    ScriptMenu += "</ScriptMenu>";
    return ScriptMenu;
}
 
function OnEvent_MenuClicked(MenuEntryId, Location, OriginWnd)
{
    if (MenuEntryId === "Toggle")
    {
        Enabled = !Enabled;
    }
}
 
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    if (Enabled)
    {
        return "< " + Message + " >";
    }
}

06-20-2010 12:39 PM
Profile E-Mail PM Find Quote Report
Barathrum
Junior Member
**

Avatar
.......................

Posts: 42
30 / Male / Flag
Joined: Nov 2009
O.P. RE: a GUI for this
Oh, awesome! Thank you!
06-20-2010 12:45 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