如何使用C#通过skype4com api静音Skype

时间:2012-12-21 01:09:15

标签: c# api skype

我只是在使用c#中的skype4com api,我对如何使用api静音Skype感到困惑。我在“skype.Mute = true;”

行上收到错误

错误:

Error   1   Ambiguity between 'SKYPE4COMLib.ISkype.Mute' and   'SKYPE4COMLib._ISkypeEvents_Event.Mute'  C:\Users\derp\documents\visual studio   2010\Projects\SkypeBot\SkypeBot\Form1.cs    33  39  SkypeBot

代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SKYPE4COMLib;

namespace SkypeBot
{
public partial class Form1 : Form
{            
    public Skype skype = new Skype();
    public bool afk;
    public Form1()
    {
        InitializeComponent();
        ((_ISkypeEvents_Event)skype).MessageStatus += OnMessageStatus;
        skype.Attach(8);
    }
    void OnMessageStatus(ChatMessage msg, TChatMessageStatus status)
    {
            if (status.ToString() == "cmsSending" && msg.Sender.DisplayName == skype.CurrentUser.DisplayName)
            {
                if (msg.Body == "!afk")
                {
                        afk = !afk;
                        if (afk)
                        {
                            msg.Body = msg.Sender.FullName + " is now afk!";

以下行是问题:

                            skype.Mute = true;
                        }
                        else
                        {
                            msg.Body = msg.Sender.FullName + " has returned!";
                        }
            }
        }
    }
}
}

1 个答案:

答案 0 :(得分:1)

我手头没有Skype API,但似乎Skype类实现了两个支持Mute属性的接口。

尝试将引用转换为特定接口,然后调用该方法,如:

((ISkype)skype).Mute = true;

((_ISkypeEvents_Event)skype).Mute = true;