Question

I'm developing an "automatic message" add-in for Office Communicator 2007, but I need to know how to identify if another user opens the IM Window (not me, but another user).

I have the following event:

private void communicator_OnIMWindowCreated(object pIMWindow)
{                     
    if ((chk_Enabled.Checked))
    {                
        IMessengerConversationWndAdvanced imWindow = pIMWindow as IMessengerConversationWndAdvanced;
        imWindow.SendText(TxtAutoMessage.Text);
    }
}

Is there a way? Thanks!

Was it helpful?

Solution

unfortunately the Communicator Automation API doesn't support this directly. The only workaround I've found involves trapping the OnIMWindowContactAdded event.

For a conversation started by you, the following events fire in this order:

  • OnIMWindowCreated
  • OnIMWindowContactAdded (for yourself)
  • OnIMWindowContactAdded (for the other participant)

For a conversation started by another participant, the following events fire in this order:

  • OnIMWindowCreated
  • OnIMWindowContactAdded (for the other participant)

So when the participant initiates the conversation, you don't see yourself added as the contact.

You could use this as follows

  • On trapping OnIMWindowCreated, store the window handle (pIMWindow.HWND) in a dictionary (so you can handle multiple conversation windows)
  • On trapping OnIMWindowContactAdded, look for the handle in the dictionary. If this is the first Added event you've seen for the window, the rule is: if the contact is you (IsSelf), then you started the conversation. Otherwise, another contact started the conversation.

It's not the most satisfactory solution (they never are when you work with the Automation API ;o) ), but it should get you there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top