Skype API Basics – Part 1

Posted by Brian R Cline | C#.NET,Programming,Windows,linux | Thursday 3 June 2010 5:48 pm

What is the Skype API?
The Skype API is an easy way to create plugins that can dramatically change the way Skype functions. For example, we could make a program that reads messages out loud as we receive them instead of having to check for new messages.

The Skype API is potentially very different for each of the operating systems Skype is available for. And, of course, there are different wrappers of the API available for some of the different languages.

What Operating Systems Are Supported?

  • Linux
  • MAC
  • Windows

What Languages Are Supported?
The Windows API,Skype4COM, is supported in literally any language that can import an ActiveX DLL or using a bit of hackery and some Skype commands we can also use Windows Messages via the Win32 SendMessage API .

Wrappers are available for additional languages that aren’t necessarily updated as frequently as Skype4COM. Skype4Java is a completely cross platform, language specific, implementation of the Skype API. Unfortunately, Skype4Java is infrequently updated and often lags behind the other implementations. Skype4Py is the other language specific implementation of the Skype API and can be used with Python on Windows and Linux.

What is Skype4COM?
Skype4COM is an ActiveX dll for use on Windows. Basically, it offers us a collection of properties, objects, and interfaces that we can use to manipulate Skype. By default, Skype4COM is installed with the Skype Extras although I always think it is prudent to provide it with our application and reference the included version.

What is Skype4Java?
Skype4Java is an older language specific wrapper for use with Java and is pretty much outdated and dying. I haven’t personally used Skype4Java, but have noticed it hasn’t been updated since 2006.

What is Skype4Py?
Skype4Py as previously mentioned is the language specific wrapper for Python and is fully supported on Linux and Windows. Skype4Py contains two different naming schemes: one follows the norms of Python, and the other set of naming conventions resembles Skype4COM.

Why use the Skype API?
There are a lot of interesting applications that make use of Skype to do telemarketing (predictive dialing even!), make Skype act like a fax machine, and even completely replace the need for a telephone! Unfortunately, my first use of the Skype API was to monitor employees that were deleting their Skype history and copy all of the messages sent and received to a location.

How should I get started?
Usually, I start reading a little bit about the API before, I begin to use it but I don’t ever focus in enough to learn the API completely unless I absolutely need to. Instead of spending your time focusing on learning APIs you should instead focus on learning computer programming fundamentals or some website development fundamentals.

More coming next week!

Determine if Skype is Installed

Posted by Brian R Cline | .NET Framework,C#.NET,Programming | Tuesday 25 May 2010 4:54 pm

The easiest method of checking whether Skype is installed is actually to check for a Registry Key. We, of course, can’t check C:\Program Files for a Skype Directory because the user could have installed elsewhere (or maybe if 64 bit the operating system did?)

Skype’s API Document provides us with the following information:

To check if Skype is installed, in regedit check if the following key exists: HKCU\Software\Skype\Phone, SkypePath . This key points to the location of the skype.exe file. If this key does not exist, check if the HKLM\Software\Skype\Phone, SkypePath key exists. If the HKCU key does not exist but the HKLM key is present, Skype has been installed from an administrator account but not been used from the current account.

Generally, I only care if the Current User has configured Skype, so I will ignore the HKEY_LOCAL_Machine information and instead rely entirely on the HKEY_CURRENT_USER information.

You must make sure you reference: Microsoft.Win32 for the registry functions or modify the snippet slightly.

        using Microsoft.Win32;

        //Function uses Microsoft.Win32 to check registry value of
        //HKEY_CURRENT_USER\Software\Skype\Phone\SkypePath and returns false if
        //the key is null
        private bool isSkypeUser()
        {
            RegistryKey skype = Registry.CurrentUser.OpenSubKey(@"Software\Skype\Phone");

            if (skype != null && skype.GetValue("SkypePath") != null)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

Books I’ve Read

Posted by Brian R Cline | .NET Framework,C#.NET,Excel,Experience,Programming,asp.net | Tuesday 8 September 2009 9:24 am

Sometimes, when I have applied for full time employment in the past I have seen job ads or received responses from companies asking what books I’ve read. Nearly every time, I have heard this question I was so shocked because I didn’t ever keep track of what I had read or where I had gleamed those little bits of valuable information.

This list will be updated at least monthly, although when I have an abundance of extra time I might be able to read an additonal book or two. Please note that this list only contains books I am interested in professionally and in no specific order.

Books Finished:

  • ASP.NET 2.0 Unleashed
  • Beginning Ubuntu Linux
  • C# How to Program
  • Code Craft: The Practice of Writing Excellent Code
  • Don’t Make Me Think: A Common Sense Approach to Web Usability
  • jQuery In Action
  • Network+ Guide to Networks
  • Learn to Program With C++
  • Practical Web 2.0 Applications with PHP
  • Systems Analysis and Design in a Changing World
  • Teach Yourself HTML 4 in 24 Hours
  • Visual Basic 6 Complete
  • Web Style Guide: Basic Design Principles for Creating Web Sites

Currently Reading:

  • Operating System Concepts

Although the list is getting pretty extensive, please understand that these are books I can verify as of September 7th 2009. The title suggests this is only books, so please remember that I definitely have visited many websites along the way.

Sending Emails from C#.NET

Posted by Brian R Cline | .NET Framework,C#.NET,Programming | Wednesday 5 August 2009 5:03 pm

Often, I work on software that needs to have the most minimal downtime possible. For example, I wrote a large chunk of server code that needs to handle CRM data for a small but completely distributed sales team. One of the methods, I use to try and reduce the downtime is to have the software email me whenever an exception is thrown or when some sort of event occurs.

Emails are incredibly easy to send from .NET especially your typical plaintext email. We will be making use of the System.Net.Mail namespace along with an smtp server you should already have setup or you could use a free one like Gmail.

A number of Canadian Internet Service Providers (ISPs) require you use their local SMTP Server (by blocking port 25), you should contact them if you think this will be an issue. Please note that some ISPs like Bell Sympatico do this to avoid being blacklisted for spam.

using System;
using System.Windows.Forms;
using System.Net.Mail;

namespace BRCline1
{
public partial class frmEmailer : Form
{
private const string SMTPServer = “Your_SMTP_Address_Or_IP_Goes_Here”;
private const string FromAddress = “The_Sender_Address_Goes_here”;
private const string FromAddressPassword = “The_Sender_Password_Goes_here”;
private const int SMTPPort = 25; //Could also be another port

public Form1()
{
InitializeComponent();
}

private void btnSend_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(SMTPServer);

mail.From = new MailAddress(FromAddress);
mail.To.Add(“address@fakedomain.com”);
mail.Subject = “Your_Subject_Goes_Here”;

//Change this boolean to true, and you could send a simple html email
mail.IsBodyHtml = false;

mail.Body = “This is my first auto email”;

SmtpServer.Port = SMTPPort;
SmtpServer.Credentials = new System.Net.NetworkCredential(FromAddress, FromAddressPassword);

SmtpServer.Send(mail);
}
}
}

Please note that you should always have some sort of exception handling for any operation that depends on a network connection or another system from responding.

Read a Whole Textfile Into a String

Posted by Brian R Cline | C#.NET,Programming | Thursday 30 July 2009 4:31 pm

At work, I’ve been working on an auto html emailer.   I’ve been receiving files from our Latin American office that are completely in spanish and trying to sift through the HTML and recreate the email taking into account size and the fact that Outlook 2007 still doesn’t accept background images and most CSS.

Anyway, one of the files they sent originally that the old software produced didn’t work. And to prove this, I had to somehow figure out how to loop through this text file they’ve been sending and prove this to my boss. I eventually found a function, that would let me avoid the looping, the steam writer and just do it.

System.IO.File.ReadAllText(String fileName)

How To Stop A .NET Form from Closing

Posted by Brian R Cline | .NET Framework,C#.NET,Programming,VB.NET | Friday 10 July 2009 1:22 pm

I always find it so amazing how people don’t or won’t bother to spend even five minutes using a search engine like Google to find out about how to do something and instead spend more time posting a question on Yahoo! Answers.

We simply add e.Cancel = true to the Form’s Closing Event, there are two simple examples below.

Closing a Form in C#.NET goes like this:

private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true
}

Closing a Form in VB.NET goes like this:

Private Sub Form1_Closing(ByVal sender As Object, ByVal e AsSystem.ComponentModel.CancelEventArgs)
e.Cancel = True
End Sub