Shoutbox

MsgPlus.ScriptRegPath| Problem :( - 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: MsgPlus.ScriptRegPath| Problem :( (/showthread.php?tid=92268)

MsgPlus.ScriptRegPath| Problem :( by m0nst3rkill3r on 09-18-2009 at 11:49 AM

Hey.
I use the registry of windows in my Script, but if i use
"MsgPlus.ScriptRegPath + Messenger.MyUserId"
I get unknown Error.
After i open the script and save it, it works :/
please help me :D


RE: MsgPlus.ScriptRegPath| Problem :( by matty on 09-18-2009 at 12:35 PM

Post the code so we can see where you are going wrong.

It is likely that you are using Messenger.MyUserId when it is not initialized therefore causing errors.

To combat issues with such events occuring this is what I do:

js code:
function OnEvent_Initialize ( ) {
    if ( Messenger.MyStatus < STATUS_INVISIBILE ) return false;
    /*
        Do stuff here like read the registry etc.
        If we make it past the first line in this function than the user
        we know is signed in.
    */
}

function OnEvent_SigninReady ( sEmail ) {
    OnEvent_Initialize (  );
}

RE: MsgPlus.ScriptRegPath| Problem :( by m0nst3rkill3r on 09-18-2009 at 02:16 PM

Heyho.

code:
var regPath;
function OnEvent_Initialize(MessengerStart){
regPath = MsgPlus.ScriptRegPath + Messenger.MyUserId;
}

function loadsettings(){
twittername = Shell.RegRead(regPath + Messenger.MyUserId +  "\\twitterusername");
twittertimer= Shell.RegRead(regPath +  "\\twittertimer");






Okay. I edited my script :

code:
var regPath;
var twitterusername;
var twittername;
var twittertimer;

function OnEvent_Initialize ( ) {
   
    if ( Messenger.MyStatus < STATUS_INVISIBILE ) return false;
    regPath = MsgPlus.ScriptRegPath + Messenger.MyUserId;
    if (twittertimer === 0){
    return false;
}
loadsettings();
MsgPlus.AddTimer("nextUpdate", twittertimer*60*1000);
}
function OnEvent_SigninReady ( sEmail ) {
    OnEvent_Initialize (  );
}

function loadsettings(){
twittername = Shell.RegRead(regPath  +  "\\twitterusername");
twittertimer= Shell.RegRead(regPath  +  "\\twittertimer");
}


does not work either
RE: MsgPlus.ScriptRegPath| Problem :( by matty on 09-18-2009 at 02:36 PM

js code:
var regPath;
var twitterusername;
var twittername;
var twittertimer;

function OnEvent_Initialize ( )
{
    if ( Messenger.MyStatus < STATUS_INVISIBILE ) return false;

    regPath = MsgPlus.ScriptRegPath + Messenger.MyUserId;
    /*
        this will never work and will always return false.
        Firstly: twittertimer is undefined. You have not assigned a value to it yet.
        Secondly load settings  is called after the check which will never get called because of the above statement
        Thirdly you are performing a bitwise comparison which means the types and value have to match.
        In this instance because WScript.Shell has no knowledge of different variable types it is loaded as a string.
        A string and a number do not match regardless if it is "0" and 0 because their types are different.
        Forthly is this the entire script? If so Shell is not declared anywhere...
    */
    if (twittertimer === 0) return false;
   
    loadsettings();
    MsgPlus.AddTimer("nextUpdate", twittertimer*60*1000);
}

function OnEvent_SigninReady ( sEmail ) {
    OnEvent_Initialize (  );
}

function loadsettings(){
    twittername = Shell.RegRead(regPath  +  "\\twitterusername");
    twittertimer= Shell.RegRead(regPath  +  "\\twittertimer");
}

I will post an update in a moment which should work.

js code:
var twitterusername;
var twittername;
var twittertimer;

function OnEvent_Initialize ( )
{
    if ( Messenger.MyStatus < STATUS_INVISIBILE ) return false;
    loadsettings(); 
    if ( twittertimer == 0 ) return false;
    MsgPlus.AddTimer( 'nextUpdate', twittertimer*60*1000 );
}

function OnEvent_SigninReady ( sEmail )
{
    OnEvent_Initialize (  );
}

function loadsettings ( )
{
    var Shell = new ActiveXObject ( 'WScript.Shell' );
    var regPath = MsgPlus.ScriptRegPath + Messenger.MyUserId;
   
    twittername = Shell.RegRead(regPath  +  '\\twitterusername');
    twittertimer = Shell.RegRead(regPath  +  '\\twittertimer');
}

RE: MsgPlus.ScriptRegPath| Problem :( by m0nst3rkill3r on 09-18-2009 at 02:42 PM

Hey.
Shell is defined above with

js code:
var Shell=new ActiveXObject("WScript.Shell");
The "Twittertimer if" i cutted out for some minutes.


/edit:
Like a chat here :D

Okay. I'll try it.


/edit:

Does not work either.

Skript wird gestartet
Skript wurde geladen und ist bereit
Aufgerufene Funktion: OnEvent_Initialize
Fehler: unbekannt (Code: -2147418113)
       Datei: I Love Twitter.js. Zeile: 91.
Funktion OnEvent_Initialize meldete einen Fehler. Code: -2147352567
Aufgerufene Funktion: OnEvent_SigninReady
Aufgerufene Funktion: OnGetScriptMenu
the 91 isue is the regPath part.

my fully code:
js code:
var twitterusername;
var twittername;
var twittertimer;
var Shell=new ActiveXObject("WScript.Shell");

function OnEvent_Initialize ( )
{
    if ( Messenger.MyStatus < STATUS_INVISIBILE ) return false;
    loadsettings(); 
    if ( twittertimer == 0 ) return false;
    MsgPlus.AddTimer( 'nextUpdate', twittertimer*60*1000 );
}

function OnEvent_SigninReady ( sEmail ) {
    OnEvent_Initialize (  );
}

function loadsettings ( )
{
    var regPath = MsgPlus.ScriptRegPath + Messenger.MyUserId;
    twittername = Shell.RegRead(regPath  +  '\\twitterusername');
    twittertimer = Shell.RegRead(regPath  +  '\\twittertimer');
}

RE: MsgPlus.ScriptRegPath| Problem :( by matty on 09-18-2009 at 02:56 PM

That cannot be all of your code because you don't have 91 lines... post all of the code and we can help.


RE: MsgPlus.ScriptRegPath| Problem :( by m0nst3rkill3r on 09-18-2009 at 02:58 PM

js code:
var username = "p3acemak3r";
var settings;
//savesettings();
var twitterusername;
var twittername;
var twittertimer;
var Shell=new ActiveXObject("WScript.Shell");



//var fileread = new ActiveXObject  ( 'Scripting.FileSystemObject' ).OpenTextFile ( "c:\\twitter.txt" , 1 ).ReadAll ( );

function OnEvent_Initialize ( )
{
    if ( Messenger.MyStatus < STATUS_INVISIBILE ) return false;
    loadsettings(); 
    if ( twittertimer == 0 ) return false;
    MsgPlus.AddTimer( 'nextUpdate', twittertimer*60*1000 );
}

function OnEvent_SigninReady ( sEmail ) {
    OnEvent_Initialize (  );
}



function OnGetScriptCommands()
{
    var ScriptCommands = "<ScriptCommands>";
    ScriptCommands    +=     "<Command>";
    ScriptCommands    +=         "<Name>tweet</Name>";
    ScriptCommands    +=         "<Description>Tweet</Description>";
    ScriptCommands    +=     "</Command>";
    ScriptCommands    += "</ScriptCommands>";

    return ScriptCommands;
}


function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}

function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    if (Message.toLowerCase() == "/tweet"){
        loadsettings();
        getTwitterStatusFromXML ( "http://www.twitter.com/status/user_timeline/"+twittername+".xml" );
        return "";
        }

}
function OnEvent_MyPsmChange(NewPsm){
    if (NewPsm.toLowerCase() === "/tweet"){
        loadsettings();
        getTwitterStatusFromXML ( "http://www.twitter.com/status/user_timeline/"+twittername+".xml" );
        return true
    }
}


function getTwitterStatusFromXML ( url )
{
    var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
    var xmldom = new ActiveXObject('Microsoft.XMLDOM');

    xmldom.async = true;
    xmlhttp.open('GET', url, true);

    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState === 4 && xmlhttp.status === 200 )
        {
            xmldom.loadXML ( xmlhttp.responseText );
            Debug.Trace (  xmldom.selectSingleNode ( '//statuses/status/text' ).text );
              Messenger.MyPersonalMessage = xmldom.selectSingleNode ( '//statuses/status/text' ).text;
              MsgPlus.DisplayToast("Personal Message: ", xmldom.selectSingleNode ( '//statuses/status/text' ).text);
        }
    }
    xmlhttp.send();
}


function loadsettings ( )
{
    var regPath = MsgPlus.ScriptRegPath + Messenger.MyUserId;
    twittername = Shell.RegRead(regPath  +  '\\twitterusername');
    twittertimer = Shell.RegRead(regPath  +  '\\twittertimer');
}
function savesettings(){
    var regPath = MsgPlus.ScriptRegPath + Messenger.MyUserId;
Shell.RegWrite(regPath  + "\\twitterusername", settings.GetControlText("username"));
Shell.RegWrite(regPath  + "\\twittertimer", settings.GetControlText("timer"));
}

function OnGetScriptMenu(){
    var myMenu = new PlusMenu;
    myMenu.addItem("Settings", "Settings");
    return myMenu.build();
}

function OnEvent_MenuClicked(sMenuId){
    if(sMenuId=="Settings"){
        loadsettings();
        OpenSettings();
       
    }
}
function OnEvent_Initialize(MessengerStart){
loadsettings();

}
function OpenSettings(){
    settings = MsgPlus.CreateWnd("winsettings.xml", "settings");
    settings.SetControlText("username", twittername);
    settings.SetControlText("timer", twittertimer);
}
function OnEvent_Uninitialize(MessengerExit){
if (twittertimer === 0){
return false;
}
MsgPlus.AddTimer("nextUpdate", twittertimer*60*1000);
}
function OnEvent_Timer(nextUpdate){
getTwitterStatusFromXML ( "http://www.twitter.com/status/user_timeline/"+twittername+".xml" );
}
function OnSettingsEvent_CtrlClicked(PlusWnd, ControlId) {
switch(ControlId) {
        default:
       
        break;
       
        case "settings_buttonSave":
            savesettings();
        break;
    }
}

RE: MsgPlus.ScriptRegPath| Problem :( by matty on 09-18-2009 at 03:05 PM

First things first you have OnEvent_Initialize defined twice.


RE: MsgPlus.ScriptRegPath| Problem :( by m0nst3rkill3r on 09-18-2009 at 03:07 PM

Ooookay.
Now my "right" function works now.
Now i get :"Fehler: 'STATUS_INVISIBILE' ist undefiniert "


RE: MsgPlus.ScriptRegPath| Problem :( by Matti on 09-18-2009 at 03:34 PM

Ahaha, that's a typo. :D Try STATUS_INVISIBLE instead:

js code:
function OnEvent_Initialize ( )
{
    if ( Messenger.MyStatus < STATUS_INVISIBLE ) return false;
    // etc...

RE: MsgPlus.ScriptRegPath| Problem :( by m0nst3rkill3r on 09-18-2009 at 03:43 PM

Thank you!, Now everything Works!