Off Topic: MSN Deskbar Clip

Since installing the MSN Toolbar suite last week (see previous posts), I've setup quite a number of shortcuts. Amongst others, this includes one called blog which points to https://weblogs.asp.net/smguest.

This is great, but people often Email me and ask "can you send me the link of your blog"?. Having these as MSN Deskbar shortcuts is great - but to extract the URL I need to launch the shortcut, wait for it to load and copy/paste from the address bar and into the Email reply.

To help make this task a little quicker, I put together a tool called MSN Deskbar Clip. It's simple - with the tool installed, you just type "clip <shortcutname>" in the MSN Deskbar. For example:

clip blog

...and it puts the URL that "blog" refers to on to the clipboard. You then simply paste it into the Email. I've found this really useful for long URLs (such as pointers to MSDN articles, products on Amazon etc.)

I've pasted the code as a sample below if you'd like to do something similar. Compile it to clip.exe and place it on your system path (e.g. c:\windows\system32). Create a new shortcut called this:

@clip, =clip $w

...and you are done. 

Enjoy.

using System;
using System.Windows.Forms;
using System.IO;

namespace msndbclip
{
public class Clip
{
[STAThread]
static void Main(String[] args)
{
if (args.Length != 1)
{
MessageBox.Show("Please run clip with the name of the MSN Deskbar shortcut.","Could not find shortcut");
return;
}

      try
{
String shortcut = args[0];
String appData = System.Environment.GetEnvironmentVariable("APPDATA");
TextReader tr = File.OpenText(appData+@"\MsnDeskbarShortcuts.ini");

        while (tr.Peek() != -1)
{
String shortcutLine = tr.ReadLine();
if (shortcutLine.ToUpper().StartsWith(shortcut.ToUpper()))
{
int eqIndex = shortcutLine.IndexOf("=");
String shortcutPath = shortcutLine.Substring(eqIndex+1,shortcutLine.Length-(eqIndex+1));
Clipboard.SetDataObject(shortcutPath,true);
return;
}
}

        MessageBox.Show("Shortcut was not found.","Could not find shortcut");
}
catch (Exception e)
{
MessageBox.Show(e.ToString(),"Something nasty happened.");
}
}
}
}