Office Communicator:如何识别 IM 窗口的打开

发布于 2024-10-02 13:09:19 字数 445 浏览 5 评论 0原文

我正在为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

下雨或天晴 2024-10-09 13:09:19

遗憾的是,Communicator Automation API 不直接支持此功能。我发现的唯一解决方法是捕获 OnIMWindowContactAdded 事件。

对于您发起的对话,将按以下顺序触发以下事件:

  • OnIMWindowCreated
  • OnIMWindowContactAdded(对于您自己)
  • 其他参与者)

OnIMWindowContactAdded(对于 由另一个参与者发起的对话,以下事件按此顺序触发:

  • OnIMWindowCreated
  • OnIMWindowContactAdded (对于另一个参与者)

因此,当参与者发起对话时,您不会看到您自己添加为联系人。

您可以按如下方式使用它

  • OnIMWindowCreated 时,将窗口句柄 (pIMWindow.HWND) 存储在字典中(这样您就可以处理多个对话窗口)
  • 在捕获 OnIMWindowContactAdded,在字典中查找句柄。如果这是您在窗口中看到的第一个“已添加”事件,则规则是:如果联系人是您 (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

  • 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文