Implementation of Skype API

karteek picture karteek · Aug 11, 2009 · Viewed 43.8k times · Source

Possible Duplicate:
Skype Addon in C#

How can I implement the Skype API to access user information in C#?

Answer

Dirk Vollmar picture Dirk Vollmar · Aug 11, 2009

UPDATE: Unfortunately, the documentation is no longer available. There is a chance though, that the below code still works, but afaik Microsoft has long planned to remove support for COM automation from Skype.


It is probably easiest to download and install the Skype API COM Wrapper.

Then you can simply add a reference to this wrapper from the COM tab of the Add References dialog in your Visual Studio project.

Below is a short sample program illustrating how to search for a user and how to send a message:

using System;
using SKYPE4COMLib;

class Program
{
    static void Main(string[] args)
    {
        Skype skype = new Skype();
        if (!skype.Client.IsRunning)
        {
            // start minimized with no splash screen
            skype.Client.Start(true, true);
        }

        // wait for the client to be connected and ready
        skype.Attach(6, true);

        // access skype objects
        Console.WriteLine("Missed message count: {0}", skype.MissedMessages.Count);

        // do some stuff
        Console.WriteLine("Enter a skype name to search for: ");
        string username = Console.ReadLine();
        foreach (User user in skype.SearchForUsers(username))
        {
            Console.WriteLine(user.FullName);
        }

        Console.WriteLine("Say hello to: ");
        username = Console.ReadLine();
        skype.SendMessage(username, "Hello World");
    }
}