Read this first - Discontinuation of Skype API
Microsoft plans to switch off the Skype desktop API in December 2013. The explanation is that:
"The Desktop API was created in 2004 and it doesn’t support mobile application development. We have, therefore, decided to retire the Desktop API in December 2013."
However, many developers are using Skype API in their products enhancing Skype functionality. And many Skype users rely on these products in their businesses and everyday life.
There is a petition initiative which requests Skype to reconsider this decision.
I have put together an example code in C# for controlling the Skype VoIP application. The Skype Control API documentation is freely available. So why not give it a try with C#?
The downloadable ZIP package contains a Visual Studio 2005 solution with two projects - the Skype Control class library and the Test Application.
The Control API for Windows uses window messages for communication between Skype and client applications. This involves usage of Windows API functions. Working with window messages is not directly supported by the .NET Framework classes. Fortunately there is a mechanism in .NET called platform invoke, which enables calls to unmanaged code in DLLs.
I will not explain the Control API in detail here, however I will provide enough information for everyone to start experimenting with the code and playing with Skype through the Test application.
Skype uses window messages to communicate with client applications. Registered window messages are used to initiate communication. The
SkypeControlAPIDiscover message is used to find the Skype window handle by broadcasting it to all windows. A client application window handle must be specified when sending this message. Skype, if running, will respond with
SkypeControlAPIAttach message sent directly to our client window.
internal class Constants
public const string SkypeControlAPIDiscover = "SkypeControlAPIDiscover";
public const string SkypeControlAPIAttach = "SkypeControlAPIAttach";
LPARAM of the
SkypeControlAPIAttach message contains the attach code. This can be
Success in case of a successful connection. When the client application tries to connect for the first time, Skype pops up an authorization dialog and notifies the client by sending
SkypeControlAPIAttach message with the
PendingAuthorisation code. Depending on the user action, Skype will next send a
public enum SkypeAttachStatus : uint
Success = 0,
PendingAuthorizaion = 1,
Refused = 2,
NotAvailable = 3,
Available = 0x8001
When the Skype application is starting, it broadcasts
SkypeControlAPIAttach message with the
Be aware that Skype assumes that our client application will process messages with result of 1 within one second, otherwise the connection times out and the communication is closed. This is important to know while debugging the client. Fortunately Skype can be set to a special "development mode" (by modifying the registry, see Skype API documentation).
WM_COPYDATA window message is used for sending Skype commands and receiving command replies and notifications.
WM_COPYDATA messages in C# is a little bit tricky. The
CopyDataStruct needs to be correctly marshaled to and from the native code. The straightforward solution is to simply pass the
CopyDataStruct this way:
public static extern IntPtr SendMessageTimeout(IntPtr windowHandle,
ref CopyDataStruct lParam,
out IntPtr result
Note that when filling
Length member also counts the terminating '
Code for getting the
CopyDataStruct form is also straightforward, the
Message class has a handy
GetLParam method for this.
Platform.CopyDataStruct aCDS =
string aResponse = aCDS.Data;
The SkypeControl Library
All the code for handling window message level communication can be found in the
SkypeClient class (
SkypeControl library). Platform specific stuff is in the Platform.cs. All of the above is internal to the Skype control library.
SkypeProxy class is designed to be used for controlling Skype by a client application. Currently, it is only wrapping calls to the
SkypeClient class and contains only methods for low level Skype API communication. It is meant to be expanded with methods that encapsulate Skype API at a higher level, e.g.
To control the Skype, just create an instance of the
SkypeProxy class. Communication is initiated by a call to
Connect. A successful connection is indicated by firing of the
SkypeAttach event with
AttachStatus set to
Commands are sent to Skype by calling
Command with appropriately formatted text command. Results and notifications from Skype are received through the
For more information on Skype Control API and command syntax, please refer to the Skype documentation which is freely available at Skype developer zones.
- 15th February, 2006: Initial post.