Here is something quick, dirty and untested:
Edit: Just realized it wont actually work because after you send a message it will be deleted from the object and the code will be fired again if they send another one...
js code:
// Create an object container
var objChatWnd = {};
// Define the message to send
var sMessageToSend = 'I have not read your message yet. But don\'t worry; I will!';
// Capture any message we send and store them in the object container
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
objChatWnd[oChatWnd.Handle] = {};
objChatWnd[oChatWnd.Handle].oChatWnd = oChatWnd;
objChatWnd[oChatWnd.Handle].sMessage = sMessage;
objChatWnd[oChatWnd.Handle].nTimer = 0;
}
// Check if we sent the message or if the contact did
function OnEvent_ChatWndReceiveMessage(oChatWnd, sOrigin, sMessage, nMessageKind) {
if (objChatWnd[oChatWnd.Handle].sMessage === sMessage &&
sMessage !== sMessageToSend) {
// Chances are that this is the message we just sent
delete objChatWnd[oChatWnd.Handle];
return sMessage;
}
if (Interop.Call('user32', 'GetForegroundWindow') !== oChatWnd.Handle) {
// A message was received but the Window isn't in the foreground
if (typeof objChatWnd[oChatWnd.Handle] !== 'object') {
// Also this is the first message received from the contact
//we wont acount for consecutive messages
objChatWnd[oChatWnd.Handle] = {};
objChatWnd[oChatWnd.Handle].oChatWnd = oChatWnd;
objChatWnd[oChatWnd.Handle].nTimer = 0;
MsgPlus.AddTimer(oChatWnd.Handle, 100);
}
}
}
// If we haven't opened the message in a minute then reply otherwise increment our counter
function OnEvent_Timer(sTimerId) {
// Chat window is open nothing further to be done here
if (Interop.Call('user32'. 'GetForegroundWindow') === sTimerId) {
/* by not deleting the object the code should never fire if the contact sends another message
after we say we didn't read it yet */
//delete objChatWnd[sTimerId];
return;
}
// Chat window hasn't been opened yet but a minute hasn't passed... increment the counter
if (objChatWnd[sTimerId].nTimer / 100 !== 60) { // 1 minute
++objChatWnd[sTimerId].nTimer;
MsgPlus.AddTimer(sTimerId, 100);
} else {
// Message hasn't been read in a minute send the message if we are allowed
if (objChatWnd[sTimerId].oChatWnd.EditChangeAllowed === true) {
objChatWnd[sTimerId].oChatWnd.SendMessage(sMessageToSend);
}
}
}