quote:
Originally posted by Matti
The reason why you're getting that error is because you're not checking how much e-mail addresses there are left in the array. You're simply incrementing the counter without checking whether it exceeds the length of the array.
By doing that, you end up with the email variable becoming undefined after a while. This won't throw an error immediately, so the script will continue and pass it as parameter to SetBinaryValue. However as soon as you try to access the length property of sKeyValue, an error will be thrown since there is no length property in undefined.
Looking at your code, it seems that you should have been able to find this out. You're tracing the value of sKeyValue at the start of SetBinaryValue so normally you should have found "sKeyValue = undefined" in your debugger.
js code:
var emailList = [ 'test1@hotmail.com', 'test2@hotmail.com', 'test3@hotmail.com', 'test4@hotmail.com' ];
// ...
function OnEvent_Initialize(MessengerStart)
{
// Check if there's anything to be done
if(emailList.length > 0) {
MsgPlus.AddTimer('windowDelayer', delayOpenWnd);
}
}
// ...
function OnEvent_Timer(timerId)
{
switch(timerId)
{
case 'windowDelayer':
var email = emailList[counter];
SetBinaryValue(HKEY_CURRENT_USER, WLMkey + '\\PerPassportSettings', 'DefaultMemberName', email);
SetStringValue(HKEY_CURRENT_USER, MPLkey, 'DefaultUser', email);
ExecuteWLM();
Debug.Trace("Set default account = " + email);
// Check if we should continue
if(counter < emailList.length) {
counter++;
MsgPlus.AddTimer('windowDelayer', delayOpenWnd);
}
break;
}
}
As you can see, despite of the debugger throwing an error inside SetBinaryValue, there was nothing wrong with that function. This is a good lesson for a developer - never rely solely on the error information!
On another note, there seems to be a few more oddities in your script:
- When the OnEvent_Initialize function is called on Messenger start-up, Messenger.MyStatus will still be 0 and thus your function will return immediately. This means that the emailList array will never be populated, causing your whole script to fail. I changed this in the code snippet above by populating the array as soon as its declared and by removing the status check at initialisation.
- What happens when the other Messenger instances are opened? Is the script going to be executed for all those instances as well? Would that mean that all those script instances will keep opening new Messenger instances? Or am I wrong about this?
Hi Matti,
I forgot about that check with length!
I did found that the "sKeyValue = undefined" in the debugger. But I thought that was because I didn't pass 4 argument to that function. I only passed 3 to it.
Well the script executes all the messenger windows and signs in all the email addresses. Then it stops. It doesn't repeat this step for all instances of messenger.
Good point though, because my 3th try making such a script opened like 8 instances of messenger over and over.
I got another quick question. Is there any way to check which email addresses have been logged in?