Javascript code:
var oContacts = [];
var Message = 'This is where your message would go.';
function OnEvent_Initialize() {
OnEvent_SigninReady();
}
function OnEvent_SigninReady() {
if (Messenger.MyStatus < STATUS_INVISIBLE) return false;
for (var eContact = new Enumerator(Messenger.MyContacts); !eContact.atEnd(); eContact.moveNext())
oContacts.push(eContact.item()); // I was missing a semi colon
MsgPlus.AddTimer('_Timer', 60000); // Run every minute | Apparently the Timer ID string cannot be empty}
function OnEvent_Timer(sTimerId) { // We're going to accept a parameter now var bSent = true;
var oChatWnd;
while (bSent === true && oContacts.length > 0) {
oChatWnd = Messenger.OpenChat(oContacts[0]);
if (oChatWnd.EditChangeAllowed === true) // Can we send a message?
bSent = oChatWnd.SendMessage(Message); // Store the result in a variable incase we've hit the flood protection
Interop.Call('user32', 'SendMessageW', oChatWnd.Handle, 0x10 /* WM_CLOSE */, 0) // Close the window regardless
if (bSent === true) // Was the message sent correctly?
oContacts.shift(); // Drop the first element of the array
else
if (oContacts.length > 0)
MsgPlus.AddTimer(sTimerId, 60000); // Run every minute | And we are going to use the parameter to re-add the timer
}
}