Knowing the hwnd of the window, how do I read the contents of this? Before anyone ask me, I'm trying to get the text that was used in the Communicator window.
Below is the code I found on the Internet. The code is not mine.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace EventFun
{
class EventHookUp
{
CommunicatorAPI.Messenger mCommunicator = null;
static void Main(string[] args)
{
EventHookUp hu = new EventHookUp();
hu.InitializeEventHocks();
Console.ReadKey();
}
public void InitializeEventHocks()
{
mCommunicator = new CommunicatorAPI.Messenger();
mCommunicator.OnIMWindowCreated += new CommunicatorAPI.DMessengerEvents_OnIMWindowCreatedEventHandler(mCommunicator_OnIMWindowCreated);
mCommunicator.OnIMWindowDestroyed += new CommunicatorAPI.DMessengerEvents_OnIMWindowDestroyedEventHandler(mCommunicator_OnIMWindowDestroyed);
}
void mCommunicator_OnIMWindowCreated(object pIMWindow)
{
CommunicatorAPI.IMessengerConversationWndAdvanced stpIMWindow = pIMWindow as CommunicatorAPI.IMessengerConversationWndAdvanced;
//stpIMWindow.History;
long Hwnd = (long)stpIMWindow.HWND;
Console.WriteLine("New IM Window Created : {0}", Hwnd);
CommunicatorAPI.IMessengerContacts contactList = (CommunicatorAPI.IMessengerContacts)stpIMWindow.Contacts;
StringBuilder sb = new StringBuilder();
foreach (CommunicatorAPI.IMessengerContact imc in contactList)
{
sb.Append(imc.FriendlyName);
sb.Append(Environment.NewLine);
}
Console.WriteLine(sb.ToString());
}
void mCommunicator_OnIMWindowDestroyed(object pIMWindow)
{
Console.WriteLine("IM Window Destroyed.");
}
}
}