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

Help:
Author: Message:
Wakaki
Junior Member
**

Avatar

Posts: 30
31 / Male / –
Joined: Jan 2007
O.P. Help:
i have a window wich is acceable from the plus menu and i have two editcontrols but i want to let them have a value wich is in an textfile and when it is changed it saves the new line to the text file so like this

you just installed the script

you open the window and the default line is loadded in the EditControl(from a textfile) so you see a text box with the default line

The user then changes the line for another line and clicks a button: save

the old line is deleted from the tectfile and replaced for the new line

then the user reopens the window

and in the textbox now is the new line

i cant seemto figure this out so
plz help mme

p.s.
If you only know a bit of this plz post it
every bit helps

This post was edited on 01-02-2007 at 02:57 PM by Wakaki.
01-02-2007 01:57 PM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Help:
If it's acessible from the Plus menu, it'll be using the event:
code:
OnEvent_MenuClicked()


Within that event you'll create the interface window (MsgPlus.CreateWnd). Then use:
code:
PlusWnd.SetControlText()


The function to read from a text file can be found on these forums, on Google and I'm fairly sure in MSDN  (as well as function to save)

Then use:
code:
OnWindowIdEvent_CtrlClicked()

and
code:
PlusWnd.GetControlText


to save the contents of the text box back to the text file...

Thats the basics. If you need any more help with the functions mentioned here, they are covered in the scripting documentation and possibly on the forum again. If you can not find the functions to Read/Write to a text file (should be really easy btw), I'll post more detail
<Eljay> "Problems encountered: shit blew up" :zippy:
01-02-2007 03:30 PM
Profile PM Find Quote Report
Wakaki
Junior Member
**

Avatar

Posts: 30
31 / Male / –
Joined: Jan 2007
O.P. RE: Help:
thank but how should i use
code:
PlusWnd.SetControlText()
this is the part that creates the window:
code:
function OnGetScriptMenu(Location)
{
    var ScriptMenu ="<ScriptMenu>";
    ScriptMenu +="<MenuEntry Id=\"window\">Polite Preferences</MenuEntry>";
    ScriptMenu +="</ScriptMenu>";
    return ScriptMenu;
}

function OnEvent_MenuClicked(MenuId, Location, Wnd)
{
    switch(MenuId)
    {
        case "window":
        MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
       
        break;
    }
       
}


so how should i use him there ??? with this default sentence:"hello nice to see you again"

btw the controlid is EdtWelcomeMsg
[Image: wakakipt2.png]
01-02-2007 03:47 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Help:
You should set a variable (like PlusWnd) which gets the return value of MsgPlus.CreateWnd, like:
code:
var PlusWnd =  MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
Then, you get the line from the file:
code:
var filePath = MsgPlus.ScriptFilesPath + "\\myfile.txt";
var sLine = new ActiveXObject('Scripting.FileSystemObject').GetFile(filePath).OpenAsTextStream(1, -1).ReadLine();
Then, you set the value using SetControlText:
code:
PlusWnd.SetControlText("EdtWelcomeMsg", sLine);

This post was edited on 01-02-2007 at 04:07 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
01-02-2007 04:06 PM
Profile E-Mail PM Web Find Quote Report
Wakaki
Junior Member
**

Avatar

Posts: 30
31 / Male / –
Joined: Jan 2007
O.P. RE: RE: Help:
quote:
Originally posted by Mattike
You should set a variable (like PlusWnd) which gets the return value of MsgPlus.CreateWnd, like:
code:
var PlusWnd =  MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
Then, you get the line from the file:
code:
var filePath = MsgPlus.ScriptFilesPath + "\\myfile.txt";
var sLine = new ActiveXObject('Scripting.FileSystemObject').GetFile(filePath).OpenAsTextStream(1, -1).ReadLine();
Then, you set the value using SetControlText:
code:
PlusWnd.SetControlText("EdtWelcomeMsg", sLine);


thank you but it is still not clear how i should use that variable is it like this?
code:
function OnGetScriptMenu(Location)
{
var ScriptMenu ="<ScriptMenu>";
ScriptMenu +="<MenuEntry Id=\"window\">Polite Preferences</MenuEntry>";
ScriptMenu +="</ScriptMenu>";
return ScriptMenu;
}

function OnEvent_MenuClicked(MenuId, Location, Wnd)
{
switch(MenuId)
{
case "window":
var filePath = MsgPlus.ScriptFilesPath + "\\myfile.txt";
var sLine = new ActiveXObject('Scripting.FileSystemObject').GetFile(filePath).OpenAsTextStream(1, -1).ReadLine();

var PlusWnd = MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
PlusWnd.SetControlText("EdtWelcomeMsg", sLine)
break;
}

}


i think actually not
but is it then like this
code:
function OnGetScriptMenu(Location)
{
var ScriptMenu ="<ScriptMenu>";
ScriptMenu +="<MenuEntry Id=\"window\">Polite Preferences</MenuEntry>";
ScriptMenu +="</ScriptMenu>";
return ScriptMenu;
}

function OnEvent_MenuClicked(MenuId, Location, Wnd)
{
switch(MenuId)
{
case "window":
var=MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );

break;
}
function readfileandsetdefault()
{
         var filePath = MsgPlus.ScriptFilesPath + "\\myfile.txt";
          var sLine = new ActiveXObject('Scripting.FileSystemObject').GetFile(filePath).OpenAsTextStream(1, -1).ReadLine();

var PlusWnd = MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
PlusWnd.SetControlText("EdtWelcomeMsg", sLine)

}


}



This post was edited on 01-02-2007 at 05:30 PM by Wakaki.
[Image: wakakipt2.png]
01-02-2007 05:25 PM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Help:
code:
function OnGetScriptMenu(Location)
{
var ScriptMenu ="<ScriptMenu>";
ScriptMenu +="<MenuEntry Id=\"window\">Polite Preferences</MenuEntry>";
ScriptMenu +="</ScriptMenu>";
return ScriptMenu;
}

function OnEvent_MenuClicked(MenuId, Location, Wnd)
{
switch(MenuId)
{
case "window":
var filePath = MsgPlus.ScriptFilesPath + "\\myfile.txt";
var sLine = new ActiveXObject('Scripting.FileSystemObject').GetFile(filePath).OpenAsTextStream(1, -1).ReadLine();

var PlusWnd = MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
PlusWnd.SetControlText("EdtWelcomeMsg", sLine)
break;
}

}


Like that. But you don't need the brackets (show in red)

EDIT: Actually the syntax is wrong there... it needs to be the FileSystemObject where it says filePath and filePath should be passed as a paramater

This post was edited on 01-02-2007 at 05:48 PM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
01-02-2007 05:40 PM
Profile PM Find Quote Report
Wakaki
Junior Member
**

Avatar

Posts: 30
31 / Male / –
Joined: Jan 2007
O.P. RE: Help:
so like this:?
code:
function OnGetScriptMenu(Location)
{
var ScriptMenu ="<ScriptMenu>";
ScriptMenu +="<MenuEntry Id=\"window\">Polite Preferences</MenuEntry>";
ScriptMenu +="</ScriptMenu>";
return ScriptMenu;
}

function OnEvent_MenuClicked(MenuId, Location, Wnd)
{
switch(MenuId)
{
case "window":
var filePath = MsgPlus.ScriptFilesPath + "\\myfile.txt";
var sLine = new ActiveXObject('Scripting.FileSystemObject').GetFile.FileSystemObject(filePath).OpenAsTextStream(1, -1).ReadLine();

var PlusWnd = MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
PlusWnd.SetControlText("EdtWelcomeMsg", sLine)
break;
}
[Image: wakakipt2.png]
01-02-2007 06:14 PM
Profile 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