7

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

4

1 回答 1

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);
        }
    }
}
于 2015-05-08T07:07:55.597 回答