Skype API消息输出

时间:2015-04-28 16:07:01

标签: c# skype skype4com

如何从Skype接收消息并将消息输出到我的应用程序(textbox1.Text)? 我在skype4com文档中寻找它但没有找到任何东西。

1 个答案:

答案 0 :(得分:2)

要收听聊天消息,您可以执行以下操作:

//First make a reference to skype4com, probably in here: C:\Program Files (x86)\Common Files\Skype
//Then use the following code:
using System;
using System.Windows.Forms;
using SKYPE4COMLib;

namespace Skype
{
    public partial class Form1 : Form
    {
        private SKYPE4COMLib.Skype skype;

        public Form1()
        {
            InitializeComponent();
            skype = new SKYPE4COMLib.Skype();
            skype.Attach(7, false);
            skype.MessageStatus += new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);
        }

        private void skype_MessageStatus(ChatMessage msg, TChatMessageStatus status)
        {
            string message = msg.Sender + ": " + msg.Body;
            listBox1.Items.Add(message);
        }
    }
}
相关问题