Click here to Skip to main content
15,880,608 members
Articles / Programming Languages / C#

Skype in Visual Studio (Visual Studio Extensibility C#)

Rate me:
Please Sign up or sign in to vote.
2.76/5 (14 votes)
3 Jul 2008CPOL3 min read 85K   50   9
Skype in Visual Studio (Visual Studio Extensibility C#)
  • Download Installer from here

Introduction

I am a .NET developer. I always chat with my partner. I think it is a waste of time to switch windows to Skype chat dialog. I created Skype integrated with Visual Studio 2005 and 2008, that allows you to chat in your Studio. It might help you save time when you need to chat and code at the same time.

This tool will help you save your time, not needing to switch in order to chat. You can wait for someone to reply on Skype chat and code at the same time. This package allows you to select your code in Visual Studio and send it to your co-worker, you can select error stack trace and send it to someone to help you. If you want more features, please let me know.

Features

  • Chat with anyone in your contact list in Visual Studio
  • Select part of code in Visual Studio and send
  • Show received message in Visual Studio

Image 1

Image 2

Background

First, you need to know about Visual Studio Extensibility and Skype API. Visual Studio allows you to add any component on it, your component should be able to connect to the Studio. You also get any information in Visual Studio that contains your component.

With the Skype API, you can do chatting and make conference calls. Skype API is a COM component, Skype that provides for Windows Form. The API allows other applications able to send/receive message, make conference and there are many events that notify Skype's behavior. You can track anything that Skype does by using the API.

Using the Code

Pre-requisites

  1. Visual Studio SDK
  2. Skype client(Version 3.5 or later)
  3. Skype API, download from https://developer.skype.com

Create Visual Studio Packages for Skype

Image 3

After you install Visual Studio SDK, there are many project templates, one of them is Visual Studio Integration Package located under Other Project Types > Extensibility on the New Project dialog box. Let's create a Skype project, Visual Studio Integration Package Wizard will show up.

  1. Select language, I prefer C# and say Generate a new key for this package.
  2. Put package information, company name, package name, version, minimum Visual Studio version and detail.
  3. Select package option, choose Tool Window
  4. Tool Windows information, Windows name is name of your window that will show in menu of Visual Studio and change "cmdidMyTool" to "cmdidSkypeTool"

Image 4

You will get a solution that Visual Studio generates for you. Press F5 for first checking, another Visual Studio instance will show up, this is Visual Studio for development environment, load difference registry with normal Studio, that Studio instance for testing our package. If everything is ok, you will see a new menu item on View>Other window>Skype.

Image 5

Now, we are ready to work on connecting to Skype via Skype API.

1. Modify Skype>MyControl.cs

Image 6

2. Load Contract List

C#
#region Constructor
public SkypeStudioControl()
{
    InitializeComponent();
    skype = new SkypeClass();
 
    //Checking for if Skype client not running, force Skype Client to start
    //Need Skype client running, if not running the Skype API will not work.
    if (!skype.Client.IsRunning)
    {
        skype.Client.Start(true, true);
        System.Threading.Thread.Sleep(300);
    }
 
    //Load contract on contract list
    this.skype.Attach(8, false);
 
    //Waiting for message from someone
    this.skype.MessageStatus += this.SkypeMessageStatusChanged;
}
#endregion

3. Send text to selected user in contact list

C#
private void btnSend_Click(object sender, EventArgs e)
{
    if (axSkypeContactList1.Selection != null && axSkypeContactList1.Selection.Count > 0)
    {
        foreach (User var in axSkypeContactList1.Selection)
        {
            skype.SendMessage(var.Handle, this.txtSendText.Text);
        }
    }
    this.txtSendText.Text = string.Empty;
}

4. Message incoming

C#
void SkypeMessageStatusChanged(ChatMessage message, TChatMessageStatus status)
{
    if (status == TChatMessageStatus.cmsReceived)
    {
        this.TextBox1.Text = string.Format("{0} : {1}", 
                             string.IsNullOrEmpty(message.Sender.FullName) ? 
				message.Sender.Handle 
                             : message.Sender.FullName, message.Body);
        Debug.WriteLine(string.Format("Add ChatMessage {0}, 
                             TChatMessageStatus {1}", 
                             message.Body, status.ToString()));
    }
}

Points of Interest

  • That will save you time when you need to chat.
  • Visual Studio Extensibility
  • Skype API

History

This is the first version. If you want me to improve this program, please let me know.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Thailand Thailand
Keng is a .NET developer working at Mycos Technologies, a software development company based in Chiang Mai, Thailand. He has been working there since 3 years and in the duration of this period has worked on several .NET projects. He is currently working on developing an application based on Amazon Flexible Payments' architecture.

Comments and Discussions

 
QuestionLogin and Password Pin
QPal-off18-Jul-11 18:59
QPal-off18-Jul-11 18:59 
Questionwindow not showing in VS2008 Pin
TheEmperor20-Jan-09 22:15
professionalTheEmperor20-Jan-09 22:15 
QuestionControl Skype Pin
KhangBKIT8-Oct-08 10:36
KhangBKIT8-Oct-08 10:36 
GeneralFix missing installer files Pin
Keng_Mycos17-Jun-08 21:50
Keng_Mycos17-Jun-08 21:50 
GeneralCool one! Pin
Rudra Lahiri31-Mar-08 14:22
Rudra Lahiri31-Mar-08 14:22 
GeneralGood concept !! Pin
Niiiissssshhhhhuuuuu31-Mar-08 10:54
Niiiissssshhhhhuuuuu31-Mar-08 10:54 
GeneralWill put more detail in this weekend Pin
Keng_Mycos25-Mar-08 7:23
Keng_Mycos25-Mar-08 7:23 
GeneralBig mistake: worng download link [modified] Pin
Keng_Mycos24-Mar-08 16:01
Keng_Mycos24-Mar-08 16:01 
I am sorry, i put worng download link. I fixed it.
About deail on my articel, i will put it more deail in this articel, how it work on both side, Visual Studio Extensibility and Skype API. I will give you all the thing.

Thank you, now you ca download from the link.

Keng is a .NET developer working at Mycos Technologies, a software development company based in Chiang Mai, Thailand. He has been working there since 3 years and in the duration of this period has worked on several .NET projects. He is currently working on developing an application based on Amazon Flexible Payments' architecture.

modified on Monday, March 24, 2008 10:20 PM

GeneralSuggestion Pin
Justin Perez24-Mar-08 13:55
Justin Perez24-Mar-08 13:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.