我在 Python 中使用 win32com 弄乱了许多 Office 程序。
Excel很好用,Outlook很简单,满足了我的基本使用需求。
我有 Microsoft Lync,但在使用时遇到问题。
我知道有限制,但我想做的是;发送消息,检测收到的消息并回复。
我使用下面的代码打开一个新窗口:
import win32com.client
msg = win32com.client.Dispatch('Communicator.UIAutomation')
msg.InstantMessage('me@me.com')
这可以很好地打开信使窗口,但任何发送消息的方法通常都会引发“未实现”错误。我知道 api 受到限制,但我想知道是否可以通过这种方式发送消息或检测收到的消息,或者是否有其他与 Communicator 通信的方式?
我真的不想使用 SendKeys 方法来编写消息。任何帮助将不胜感激。
最佳答案
与其尝试驱动 Communicator GUI 程序,不如考虑实现底层聊天协议(protocol)的接口(interface)。
Communicator 可以说 XMPP protocol - 与 Google Talk、Facebook Chat 等相同。
来自维基百科:
Furthermore, several enterprise IM software products that do not natively use XMPP nevertheless include gateways to XMPP, including:
- IBM Lotus Sametime
- Microsoft Lync Server (formerly named Microsoft Office Communications Server – OCS)
您应该能够实现自己的 XMPP 客户端。 libpurple
, Pidgin 背后的聊天协议(protocol)库, 实现 XMPP;如果你愿意,你可以使用它。
关于Python - Office Communicator API - 是否可以在有限制的情况下发送消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10581740/