Hi Matti,
I got it almost completely working with your guidance. I still got a minor problem.
Here is my code:
JScript code:
var emailList = new Array();
var counter = 0;
var delayOpenWnd = 2000;
var MPLkey = 'SOFTWARE\\Patchou\\Messenger Plus! Live';
var WLMkey;
var WLMexe;
if(Messenger.Version >= 8.5)
{
WLMkey = 'SOFTWARE\\Microsoft\\MSNMessenger';
WLMexe = 'SOFTWARE\\Microsoft\\Windows Live\\Messenger';
}
else
{
WLMkey = 'SOFTWARE\\Microsoft\\MSNMessenger';
WLMexe = WLMkey;
}
function OnEvent_Initialize(MessengerStart)
{
if ( Messenger.MyStatus < STATUS_INVISIBLE ) return;
emailList.push('test1@hotmail.com');
emailList.push('test2@hotmail.com');
emailList.push('test3@hotmail.com');
emailList.push('test4@hotmail.com');
MsgPlus.AddTimer('windowDelayer', delayOpenWnd);
}
function OnEvent_Uninitialize(MessengerExit)
{
MsgPlus.CancelTimer('windowDelayer');
}
function ExecuteWLM()
{
new ActiveXObject("Shell.Application").ShellExecute("C:/Program Files (x86)/Windows Live/Messenger/" + "msnmsgr.exe", "", "", "open", 1);
}
function OnEvent_Timer(timerId)
{
switch(timerId)
{
case 'windowDelayer':
var email = emailList[counter];
counter++;
SetBinaryValue(HKEY_CURRENT_USER, WLMkey + '\\PerPassportSettings', 'DefaultMemberName', email);
SetStringValue(HKEY_CURRENT_USER, MPLkey, 'DefaultUser', email);
ExecuteWLM();
Debug.Trace("Set default account = " + email);
MsgPlus.AddTimer('windowDelayer', delayOpenWnd);
break;
default:
}
}
function OnEvent_SigninReady(emailaddr)
{
var emailstat = Messenger.MyEmail;
if(Messenger.MyStatus != STATUS_UNKNOWN)
{
Debug.Trace("User signed in, email = " = emailaddr + '\n');
Debug.Trace("emailstat = " + emailstat + '\n');
}
}
I got another quick question. Is there anything in this code that I don't need? for example the OnEvent_SigninReady?
Not sure what it should do.
Also, the function SetBinaryValue takes 4 arguments, but i'm only passing it 3.
JScript code:
function SetBinaryValue(lKeyLocation, sKey, sKeyName, sKeyValue)
{
Debug.Trace("sKeyValue = " + sKeyValue);
var hKey = Interop.Allocate(4);
var lBufferSize = Interop.Allocate(4);
lBufferSize.WriteDWORD(0, 2 * sKeyValue.length + 2);
var lRetVal = Interop.Call('advapi32.dll', 'RegOpenKeyExW', lKeyLocation, sKey, 0, KEY_WRITE, hKey);
if(lRetVal == ERROR_SUCCESS)
{
lRetVal = Interop.Call('advapi32.dll', 'RegSetValueExW', hKey.ReadDWORD(0), sKeyName, 0, REG_BINARY, sKeyValue, lBufferSize.ReadDWORD(0));
if(lRetVal == ERROR_SUCCESS)
{
CloseKey(hKey);
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
Any idea what sKeyValue should be?
It gives me an error in the debug window. It says:
Error: 'length' is null or not an object (code: -2146823281)
File: _Registry.js. Line: 145.
This would be the affected line:
lBufferSize.WriteDWORD(0, 2 * sKeyValue.length + 2);
In function:
SetBinaryValue()