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

Pages: (3): « First [ 1 ] 2 3 » Last »
RegWrite Causing Errors?
Author: Message:
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
O.P. RegWrite Causing Errors?
quote:
Originally posted by The Debug Window
Error: .
       Line: 135. Code: -2147418113.
Function OnEvent_Initialize returned an error. Code: -2147352567

line 135 is
code:
WriteRegistry("OldPSM",Messenger.MyPersonalMessage);

and the WriteRegistry function is
code:
function WriteRegistry(key, value){
Debug.Trace("WRITE REGISTRY - "+key + ": "+value);
return new ActiveXObject("WScript.Shell").RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\" + key, value, "REG_SZ");
}


Any ideas why I'm getting the error? Am I missing something really stupid?

PS: This scripts used to work, so I don't know why it's gone funny :s

EDIT: Also, this only happens the first time the script is run once WLM opens... If you disbale it and then enable it again it works properly

This post was edited on 09-14-2006 at 04:29 PM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
09-14-2006 04:28 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: RegWrite Causing Errors?
This is caused since Messenger.MyEmail is undefined. It works when you re-enable it since you're logged in and the email is set. Therefore, try this:
code:
function OnEvent_Initialize(MessengerStart) {
   if(MessengerStart && Messenger.MyStatus > 1) {
       OnEvent_SigninReady(Messenger.MyEmail); //Call the event like a normal function
   }
}
function OnEvent_SigninReady(Email) {
   //Original code for OnEvent_Initialize goes here
}
This will make the function do what it has to do when the signin is ready, and when it's initialized if you're signed in. ;)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
09-14-2006 04:39 PM
Profile E-Mail PM Web Find Quote Report
R4000
Junior Member
**

W2M - GD Script Creator

Posts: 44
33 / Male / –
Joined: May 2006
RE: RegWrite Causing Errors?
I suggest reg functions like:

code:
function WriteRegistry(key, value)
{
    var Shell = new ActiveXObject("WScript.Shell");
    try {
        return Shell.RegWrite(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\" + key, value);
    } catch(e) {
        return false;
    }
}


function ReadRegistry(key)
{
    var Shell = new ActiveXObject("WScript.Shell");
    try {
        return Shell.RegRead(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\" + key);
    } catch(e) {
        return false;
    }
}

function RemoveRegistry(key)
{
     var Shell = new ActiveXObject("Wscript.Shell");
    try {     
        return Shell.RegDelete(MsgPlus.ScriptRegPath + Messenger.MyEmail + "\\" + key);
    } catch(e) {
        return false;
    }
}

then you have error catching if the key doesnt exist and you try to read it or w/e
(its wierd but i try to read b4 i write :P)
[Image: msnsig/]
This image stops working when my PC is off, it isn't bad coding :)
The source to the image above. | MSN: peter@gsf.tv
09-14-2006 05:04 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
O.P. RE: RegWrite Causing Errors?
Thankyou both. Just changed the code and I'm testing it out and I've sent it to a few others to try, but it seems to work (apart from still causing an OnEvent_Initialize error in the debug window)

EDIT: Thought it was working, but it still throws an error at the same line, meaning I can't read any of the settings for the script... It only starts working when it's re-renabled... Any ideas?

This post was edited on 09-14-2006 at 06:24 PM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
09-14-2006 05:12 PM
Profile PM Find Quote Report
phalanxii
Full Member
***


Posts: 146
Reputation: 5
32 / Male / Flag
Joined: Aug 2006
Status: Away
RE: RegWrite Causing Errors?
Mattike has got the right idea, but if I'm not mistaken, shouldn't it be:
code:
function OnEvent_Initialize(MessengerStart) {
   if(!MessengerStart && Messenger.MyStatus > 1) {
       OnEvent_SigninReady(Messenger.MyEmail); //Call the event like a normal function
   }
}
function OnEvent_SigninReady(Email) {
   //Original code for OnEvent_Initialize goes here
}
That way, OnEvent_SigninReady executes when a) the script is enabled when Messenger is signed in and b) when you sign in to Messenger. Also, if you don't need any details from contacts, you can use OnEvent_Signin instead, as this will give the same result, but a lot earlier.
09-15-2006 12:02 AM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: RegWrite Causing Errors?
quote:
Originally posted by Mattike
code:
if(MessengerStart && Messenger.MyStatus > 1)

As phalanxii pointed out, this is wrong and can never become true since if MessengerStart is true, Messenger.MyStatus will always be 0.

However...
quote:
Originally posted by phalanxii
but if I'm not mistaken, shouldn't it be:
code:
function OnEvent_Initialize(MessengerStart) {
   if(!MessengerStart && Messenger.MyStatus > 1) {
       OnEvent_SigninReady(Messenger.MyEmail); //Call the event like a normal function
   }
}
function OnEvent_SigninReady(Email) {
   //Original code for OnEvent_Initialize goes here
}
That way, OnEvent_SigninReady executes when a) the script is enabled when Messenger is signed in and b) when you sign in to Messenger. Also, if you don't need any details from contacts, you can use OnEvent_Signin instead, as this will give the same result, but a lot earlier.

That's not correct either though. The stuff in SigninReady will not be executed when Messenger is started the first time...

And if you check on Messenger.MyStatus you do not need to check on MessengerStart too.

Because if Messenger is started the first time, your status (and email) can not be something as you still need to sign in.

If the script is restarted (and thus MessengerStart is false) the important thing is again your status. If that is 0 (not signed in), Messenger.MyEmail will not be defined. If you are signed in, Messenger.MyEmail will be defined.

So, the proper code you want is:
code:
function OnEvent_Initialize(MessengerStart) {
   if(Messenger.MyStatus > 0) {
       OnEvent_SigninReady(Messenger.MyEmail);
   }
}
function OnEvent_SigninReady(Email) {
   //Original code for OnEvent_Initialize goes here
}
1) you start messenger thus script is started for the first time:
  OnEvent_Initialize is called
    MessengerStart is true
    Messenger.MyStatus is 0
    Messenger.MyEmail is undefined

2) you restart the script:
  OnEvent_Initialize is called
    MessengerStart is false
    Messenger.MyStatus is 0
    Messenger.MyEmail is undefined

3) you sign in:
  OnEvent_Signin(Ready) is called
    Messenger.MyStatus is >0
    Messenger.MyEmail is defined

4) you restart the script:
  OnEvent_Initialize is called
    MessengerStart is false
    Messenger.MyStatus is >0
    Messenger.MyEmail is defined

5) you sign out and then you restart the script
  see 2

This post was edited on 09-15-2006 at 10:28 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
09-15-2006 10:16 AM
Profile PM Find Quote Report
phalanxii
Full Member
***


Posts: 146
Reputation: 5
32 / Male / Flag
Joined: Aug 2006
Status: Away
RE: RegWrite Causing Errors?
Ah yeah, sorry about that. I forgot about the status being 0 when you're not signed (so the code isn't executed). What I actually meant was:
code:
function OnEvent_Initialize(MessengerStart) {
   if(!MessengerStart) {
       OnEvent_SigninReady(Messenger.MyEmail); //Call the event like a normal function
   }
}
function OnEvent_SigninReady(Email) {
   //Original code for OnEvent_Initialize goes here
}
Cookie's code works exactly the same, so it doesn't really matter. :)
09-15-2006 01:14 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: RegWrite Causing Errors?
quote:
Originally posted by phalanxii
Mattike has got the right idea, but if I'm not mistaken, shouldn't it be:
code:
...

Woops! You're right. :$

quote:
Originally posted by phalanxii
I don't think my code is wrong either *-)... although your code works just as well.
But what you forget is:

4. You have imported the script while you are signed out:
   OnEvent_Initialize is called.
   MessengerStart is false, so !MessengerStart is true.
   The if statement in OnEvent_Initialize is executed.
   OnEvent_Signin is called.
   Messenger.MyEmail is undefined (you are signed out).
     TUUT! Error!

So, the only way it should work is by using both !MessengerStart and Messenger.MyStatus > 0. ;)

quote:
Originally posted by phalanxii
I would also use OnEvent_Signin instead of OnEvent_SigninReady because it is called a lot earlier. Though OnEvent_Signin is called when not all information is available, for SpunkyLoveMuff's purpose of writing settings into the registry, contact information is not required (if it is, then use OnEvent_SigninReady ;)).
You can, it just depends on how urgent the keys should be imported. :)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
09-15-2006 01:17 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: RegWrite Causing Errors?
quote:
Originally posted by phalanxii
Ah yeah, sorry about that. I forgot about the status being 0 when you're not signed (so the code isn't executed). What I actually meant was:
code:
function OnEvent_Initialize(MessengerStart) {
   if(!MessengerStart) {
       OnEvent_SigninReady(Messenger.MyEmail); //Call the event like a normal function
   }
}
function OnEvent_SigninReady(Email) {
   //Original code for OnEvent_Initialize goes here
}
Cookie's code works exactly the same, so it doesn't really matter. :)
no it isn't the same and doesn't work the same....

Open Messenger, before signing in, restart the script. You'll see that with your method (if(!MessengerStart)) your script will end in an error, while mine (if(Messenger.MyStatus > 0)) doesn't.

quote:
Originally posted by Mattike
(...)
So, the only way it should work is by using both !MessengerStart and Messenger.MyStatus > 0. ;)
!MessengerStart isn't needed at all... see my previous post which explains all the possible events in a pseudo boolean algebra truth table. Look at the sequence of events and look at the states of things, you'll see that to have a defined email, the only thing to check is the status being >0.

many script make this error (in fact I think I have made some scripts myself with that very same error... :/... me goes to check)...

This post was edited on 09-15-2006 at 10:12 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
09-15-2006 10:03 PM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
O.P. RE: RegWrite Causing Errors?
Thanks for the help guys. Cookie's solution appears to have worked :D

I'm reading a comma seperated list from the registry and reading it into an array and then placing it into a List View box thingy :p  This needs to be done ASAP as the window is opened when the script starts... (it then gets hidden until it's needed)

Like I said, if(Messenger.MyStatus > 0) seems to work for what I want at the moment... Thanks :)
<Eljay> "Problems encountered: shit blew up" :zippy:
09-15-2006 10:18 PM
Profile PM Find Quote Report
Pages: (3): « First [ 1 ] 2 3 » Last »
« 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