Office Communicator:如何识别 IM 窗口的打开
我正在为 Office Communicator 2007 开发一个“自动消息”加载项,但我需要知道如何识别是否另一个用户(不是我,而是另一个用户)打开了 IM 窗口。
我有以下事件:
private void communicator_OnIMWindowCreated(object pIMWindow)
{
if ((chk_Enabled.Checked))
{
IMessengerConversationWndAdvanced imWindow = pIMWindow as IMessengerConversationWndAdvanced;
imWindow.SendText(TxtAutoMessage.Text);
}
}
有办法吗?谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
遗憾的是,Communicator Automation API 不直接支持此功能。我发现的唯一解决方法是捕获
OnIMWindowContactAdded
事件。对于您发起的对话,将按以下顺序触发以下事件:
OnIMWindowCreated
OnIMWindowContactAdded
(对于您自己)OnIMWindowContactAdded
(对于 由另一个参与者发起的对话,以下事件按此顺序触发:OnIMWindowCreated
OnIMWindowContactAdded
(对于另一个参与者)因此,当参与者发起对话时,您不会看到您自己添加为联系人。
您可以按如下方式使用它
OnIMWindowCreated
时,将窗口句柄 (pIMWindow.HWND
) 存储在字典中(这样您就可以处理多个对话窗口)IsSelf
),则您开始了对话。否则,另一位联系人开始了对话。这不是最令人满意的解决方案(当您使用自动化 API 时,它们永远不是最令人满意的解决方案;o)),但它应该可以帮助您实现这一目标。
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
OnIMWindowCreated
, store the window handle (pIMWindow.HWND
) in a dictionary (so you can handle multiple conversation windows)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.