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:
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
« Next Oldest Return to Top Next Newest »

Messages In This Thread
a GUI for this - by Barathrum on 06-20-2010 at 08:24 AM
RE: a GUI for this - by NanaFreak on 06-20-2010 at 08:58 AM
RE: a GUI for this - by Barathrum on 06-20-2010 at 09:11 AM
RE: a GUI for this - by whiz on 06-20-2010 at 10:11 AM
RE: a GUI for this - by Barathrum on 06-20-2010 at 12:06 PM
RE: a GUI for this - by Menthix on 06-20-2010 at 12:27 PM
RE: a GUI for this - by whiz on 06-20-2010 at 12:39 PM
RE: a GUI for this - by Barathrum on 06-20-2010 at 12:45 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