Showing posts with label Skype. Show all posts
Showing posts with label Skype. Show all posts

Aug 14, 2008

Skype4COMLib and Blogger - get your posts as a mood text in skype (or do whatever you want with skype ;).

My dear friend Bobby is going on vacation today at 6 p.m. Since I’m going to miss her while she’s taking her vacation on Black Sea I decided to play a bit with Skype4COM and write a small program for her.


This is where everything started ;) (thanks, Bobby for the inspiration ;).
She had her skype mood text set to how many days are until her vacation takes place. I wanted to help her so I wrote a simple tool to countdown until 6 p.m. and change her Skype mood accordingly.

Well I am not going to explain you how I did this. I got better idea later. I decided to make a mood changer for me. The mood changer will take my blogger posts and rotate them as skype mood text.

Skype Mood Text Changer, made with Skype4COM Lib and .NET C#

First of all, where should I get my posts from? Well, there are two ways I can think of. The first one is to use the Blogger API (login with the user, get all user blogs, get all user posts, etc.).
The second one is to use the RSS feed that blogger automatically creates for each blog.
Since this is very small tool I think the first approach is too “heavy” and “complex”. After all we aren’t going to post to the blog or anything that will require us to login in Blogger. So I took the RSS approach.

Let’s see how you can create a small program to do this for you:
1. Start new windows application.
2. Right click your References folder in the solution explorer and choose Add Reference …
3. In the dialog box click on the “COM” tab and find Skype4COMLib.
4. Click OK.

Now you have that skype thing referenced in your project. Add it to your using clause:

using SKYPE4COMLib;

After we are here, and we know we are going to use RSS, we will need Xml namespace as well. Add it too:

using System.Xml;

Okay. In my approach, I wanted to display random post on every 10 seconds. This means I will need to store a post title -> post link pair somewhere. I did this in a generic List of string[] arrays. I am not quite sure how optimized is this but this is only sample and it works fine for me. If you can think of something more optimized - please do not hesitate to write a comment ;). For now, however, add the System.Collections namespace to your using clause:

using System.Collections;

Okay, we have everything we will need to create our small tool. Now add a timer on your form. It’s timer1 in my sample. Set it's interval to 10000 (10 seconds).

Add the following global variables to your project:

List<string[]> posts = new List<string[]>();
private SKYPE4COMLib.Skype skype;

Here is how your Form_Load event should look like:

    
private void Form1_Load(object sender, EventArgs e)
     {
        skype =
new SkypeClass();
        
this.WindowState = FormWindowState.Minimized;
        GetBlogs();
        timer1.Enabled =
true;
     }

What I want you to note in the Page_Load is that I am assigning the skype variable. This way it will remain linked to your skype until the program is runned.

I used routine GetBlogs() in this project, here is it:

private void GetBlogs()
{
XmlDocument docRSS = new XmlDocument();
docRSS.Load(
"http://donchevp.blogspot.com/feeds/posts/default?alt=rss");
    
foreach (XmlNode nodeItem in docRSS.SelectNodes("/rss/channel/item"))
    {
    
string title = nodeItem.SelectSingleNode("title").InnerText;
        
string href = nodeItem.SelectSingleNode("link").InnerText;
posts.Add(
new string[] { href, title });
    }

}


NOTE: replace the url in the docRSS.Load() method, otherwise you will promote my blog ;).

This routine simply takes all the posts and stores them in the List of string arrays as link, title pairs.
Now we need to display the posts as title “-“ link. This will happen in the timer1_Tick event:

private void timer1_Tick(object sender, EventArgs e)
{
int iPostIndex = int.MinValue;
    
if (posts.Count > 0)
    {
    
Random rnd = new Random();
        iPostIndex = rnd.Next(0, posts.Count);
        skype.CurrentUserProfile.MoodText = posts[iPostIndex][1] +
" - " + posts[iPostIndex][0];
}
}

Everything seems to work fine now. Run your program. Skype should ask you if you are sure you want to give access to this program to use skype. Agree with that. You should now see your posts rotating each 10 seconds.

Here is the complete code (I will also upload the project on Chameleon Bulgaria site, as codes in Blogger doesn’t appear very smoothly):

Form1.cs:

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

namespace dayOffCounter
{
  
public partial class Form1 : Form
   {
    
List<string[]> posts = new List<string[]>();
    
private SKYPE4COMLib.Skype skype;
    
public Form1()
     {
        InitializeComponent();
     }

    
private void Form1_Load(object sender, EventArgs e)
     {
        skype =
new SkypeClass();
        
this.WindowState = FormWindowState.Minimized;
        GetBlogs();
        timer1.Enabled =
true;
     }

    
private void GetBlogs()
     {
        
XmlDocument docRSS = new XmlDocument();
        docRSS.Load(
"http://donchevp.blogspot.com/feeds/posts/default?alt=rss");
        
foreach (XmlNode nodeItem in docRSS.SelectNodes("/rss/channel/item"))
        {
          
string title = nodeItem.SelectSingleNode("title").InnerText;
          
string href = nodeItem.SelectSingleNode("link").InnerText;

           posts.Add(
new string[] { href, title });
        }
     }

    
private void timer1_Tick(object sender, EventArgs e)
     {
        
int iPostIndex = int.MinValue;
        
if (posts.Count > 0)
        {
          
Random rnd = new Random();
           iPostIndex = rnd.Next(0, posts.Count);
           skype.CurrentUserProfile.MoodText = posts[iPostIndex][1] +
" - " + posts[iPostIndex][0];
        }
     }
   }
}

Things to consider: Unfortunately skype has some constraints we can not avoid. First of all - the text seems to be too short to hold some of my posts, which results in links not being rendered correctly and leading to a wrong page (or even worse - to a page that doesn’t exist). I really wish to be able to set click here links as a mood text but it is not possible for now (at least I couldn’t find such functionality).

Happy codding!

Skype4COM Lib - how to register Skype ?


I wrote few tools, which only worked on my computer and not on the computer of my collegue - Bobby. She was having newer version of Skype and in the beggining I assumed it is a protocol problem. It finally appeared that the problem is her computer not having Skype4COMLib registered. So if you run in such a trouble, do the following :

1. Find the Skype4COM.dll file on your computer (typically it is in : C:\Program Files\Common Files\Skype)
2. Go to your Start Menu -> Run ...
3. Type cmd
4. In the command prompt type : regsvr32 Skype4COM.dll or "regsvr32 C:\Program Files\Common Files\Skype\Skype4COM.dll" depending on in which directory you are with the cmd (note the quotes that surround the path ;) ...


Everything should be fine now.

NOTE: I am writing this post not because it is something complex, but because I often forget how to register something ... Especially Skype :). Now I (and you) will have a reference, so don't be shy, add this post to your bookmarks :P

P.S. I hope I will be able to write a small tool to register Skype4COMLib

Mar 24, 2008

Finally its here ...

Skype passport 1.0 is out, you can find the simple html page on Chameleon Bulgaria



Online demo: Here



Download page: Here
>

Mar 20, 2008

World's first Skype Passport is almost out ;)

This is a little javascript which will allow your users to easilly register on your site, by filling their contacts automatically from skype (offcourse only few fields are populated, but most registrations require only few fields after all).
Here is a screenshot of this neat little javascript placed on a page:



Note : This works only if your users are using IE (as this thing depends on ActiveX).

The tool will be available for free download at my site : ChameleonBulgaria so visit it regularly ;)

When I publish it, I will also publish a news on the frontend so you can know.
Just a few more hours ;)
.

Jun 30, 2007

Skype API (Skype4COM) + Google MAPS API = ? [3]

As a part of my Google Maps and Skype API I wanted to add custom icons to represent different objects on the map (currently I made it for the bus stations).

The picture bellow is the result :



It was again easy - we simply create GIcon object. Then we assign the URL of the image to be used, size of the icon and point, where the info window will appear :


Code


icon = new GIcon();
icon.image = 'BusFine.gif';
icon.iconSize = new GSize(39, 60);
icon.iconAnchor = new GPoint(5, 34);
icon.infoWindowAnchor = new GPoint(5, 2);




Then we only need to add this object as a second parameter in the GMarker object constructor.



Code


// point is a GPoint object, representing the location the marker
should be
// displayed.
marker = new GMarker(point, icon);



Note : Some browsers may need some more settings in order to display the custom icon correctly, the example above is for IE.

Jun 18, 2007

Skype API (Skype4COM) + Google MAPS API = ? [2]

The last few days I played a bit more with this little thing and made it a bit more stable.  First of all there were some strange silver rectangles in the map (which I suspect is becouse I use IE) another struggle was to force the map not to resize (pretty strange, huh?). I solved both issues at once by adding overflow="hidden"  style attribute to the div, containing the map. It is quite strange.  I also added the stnadard map types controls (Map, Satellite and Hybrid), that wasn't hard but took a lot of search in the net, I had the feeling that I need to define my layer, I don't know why but in the end I understood I only need to call : map.addControl(new GMapTypeControl()); it simply cannot be more easier. After the lesson with
the map type control it was a line of code to add the large zoom control : map.addControl(new GLargeMapControl()); the guys from Google really rule the world :). They made it as easy as possible. After I got the map types and the zoom control I wanted some challenge. I decided to add a tabbed info window, only for the test the first tab I wanted was : "User Info" and I wanted the second to be "Date of birth" that was again as easy as possible ! Nice work, googlers !

Finally here is what I have so far :


I will try to add custom layers and lines these days only to test how it works and is it hard to implement.

Jun 9, 2007

Skype API (Skype4COM) + Google MAPS API = ?

I've played a bit last few days. I was interested in mixing the Skype4COM library (Official Skype API) with the Google Maps API (Google's Geocoding Service). It was quite tricky to make them both work properly, but finally I got some "results". Screenshots of the results will be published in this post the next few days, since I have some difficulties using the blogger upload utility (probably it is becouse my ISP, not blogger itself).









And this is what I have done with Skype (Skype4COM) and Google Maps Api. I am thinking on how to incorporate this program into skype (probably as plugin or something) so it can be easier to use.

>