MSN Desktop Search Clip
A few months back I blogged about a clip utility that I'd put together for MSN Desktop Search. This tool copies MSN Desktop shortcuts to the clipboard - for pasting into other applications. For those that use MSN Desktop Search, let's imagine I've defined a shortcut called "myblog":
@myblog, https://blogs.msdn.com/smguest
With this utility in my path, I simply type the following into the MSN Desktop Search window:
clip myblog
...and the link gets pulled from MSN Desktop Search and into the clipboard. I've found this to be a good time saver for the "can you please send me the link to your blog?" emails.
Here's the source code for this (which has been updated for the newest release of MSN Desktop Search - hence the reason for this post)
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+@"\MSN Search Toolbar\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.");
}
}
}
}