Shoutbox

AutoAnswer 1.00 [But scripts are not running.] Please help me - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: AutoAnswer 1.00 [But scripts are not running.] Please help me (/showthread.php?tid=94948)

AutoAnswer 1.00 [But scripts are not running.] Please help me by notza082 on 07-05-2010 at 01:37 PM

Hello. I've tried to make an auto message on msn. But when I downloaded this script, I didn't know where to write any thing.

I edit the text in AutoAnswer.INI

But scripts are not running :(

Please help me

Thank you

code:
// AutoAnswer - Messenger Plus! Live Script
//
// Version: 1.0
//
// By Dave Nottage - davidn@radsoft.com.au
//
// See readme.txt for info about this script
//
// This is my first ever Messenger Plus! Live Script

var
  LastUserMessage = '';
  AutoMessage = '';
  AutoSendTimerId = 'AutoSendMessage';
  AutoDelayTimerId = 'AutoSendDelay';
  LastChatWnd = null;
  NullChar = String.fromCharCode(0);
  WM_KEYDOWN = 0x0100;
  WM_KEYUP   = 0x0101;
  WM_CHAR    = 0x0102;
  SW_SHOWNORMAL = 1;
  FakeKey = 'T';

  AutoAnswerDLL = MsgPlus.ScriptFilesPath + '\\AutoAnswer.DLL';
  AutoAnswerConfigFile = MsgPlus.ScriptFilesPath + '\\AutoAnswer.INI'
  AutoAnswerConfigSection = 'Configuration';
  AutoAnswerCallGetResponse = 'GetResponse';
  // AutoAnswerCallFakeInput = 'FakeInput';
 
 
function IniReadInteger(Ident, Default)
{
  return Interop.Call('Kernel32', 'GetPrivateProfileIntW', AutoAnswerConfigSection , Ident, Default, AutoAnswerConfigFile);
}
 
function OpenContactChatWnd(Wnd)
{
  Contacts = new Enumerator(Wnd.Contacts);
  Contacts.moveFirst;
  Contact = Contacts.item();
  Messenger.OpenChat(Contact.Email);
}

// Used to fake an input to a chat window by posting keyboard events
function FakeInput(Wnd)
{
  // Initiate the chat window
  OpenContactChatWnd(Wnd);
  // Find the message edit window
  UIWnd = Interop.Call('User32', 'FindWindowExW', Wnd.Handle, 0, 'DirectUIHWND', null);
  if (UIWnd != 0)
  {
    Key = FakeKey.charCodeAt(0);
    VirtKey = Interop.Call('User32', 'MapVirtualKeyW', Key, 0);
    LParam = VirtKey << 16;
    // Fake a keystroke
    Interop.Call('User32', 'PostMessageW', UIWnd, WM_CHAR, Key, LParam || 0xC0000000);
  }
}

function StringOfChar(Char, Length)
{
  var S = '';
  while (S.length < Length)
  {
    S = S + Char;
  }
  return S
}

function OnEvent_Initialize(MessengerStart)
{
  TypingDelayPerChar = IniReadInteger('TypingDelayPerChar ', 125);
  ReadingDelayPerChar = IniReadInteger('ReadingDelayPerChar', 50);
  AutoResponseDelay = IniReadInteger('AutoResponseDelay', 300);
  MaxReplyLength = IniReadInteger('MaxReplyLength', 512);
}

function OnEvent_Uninitialize(MessengerExit)
{

}

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
  LastChatWnd = null;
  if (MessageKind == 1)
  {
    if (Message != LastUserMessage)
    {
      // Save the chat window object
      LastChatWnd = ChatWnd;
      AutoMessage = StringOfChar(' ', MaxReplyLength);
      // Call the autoanswer dll
      Interop.Call(AutoAnswerDLL, AutoAnswerCallGetResponse, Origin, Message, AutoMessage);
      // Trim the returned message
      AutoMessage = AutoMessage.substring(0, AutoMessage.indexOf(NullChar));
      if (AutoMessage.length > 0)
      {
        // Start a timer to fake reading time
        MsgPlus.AddTimer(AutoDelayTimerId, (Message.length * ReadingDelayPerChar) + AutoResponseDelay);
      }
    }
    LastUserMessage = '';
  }
}

function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
  // Save the last message sent by this user
  LastUserMessage = Message;
}

function OnEvent_Timer(TimerId)
{
  // Cancel the timer since it has fired
  MsgPlus.CancelTimer(TimerId);
  if (TimerId == AutoSendTimerId)
  {
    if (LastChatWnd != null)
    {
      // Cancel the editing that FakeInput created
      LastChatWnd.EditText = '';
      // Send the automated response
      LastChatWnd.SendMessage(AutoMessage);
      LastChatWnd = null;
    }
  }
  if (TimerId == AutoDelayTimerId)
  {
    // FakeInput is used to make the other user think this one is typing
    FakeInput(LastChatWnd);
    MsgPlus.AddTimer(AutoSendTimerId , AutoMessage.length * TypingDelayPerChar);
  }
}