Contents
Introduction
Do you listen to podcasts that have Shrinkster.com links in them?
Shrinkster provides a service where it takes a url, compresses it, and allows you to use this compressed url in place of a long url.
As I'm listening to a podcast and a Shrinkster code is mentioned, I would switch to a browser and type www.shrinkster.com/thecode, hit enter and then be transported to that page.
After typing the Shrinkster url a few times I thought a short cut was in order, which led to this this small Windows utility that opens a new IE browser when you enter a Shrinkster code.
The utility does only one thing: opens a new browser, with the Shrinkster url and code preloaded. Shrinkster will then redirect you to the uncompressed url.
I'll explain the usage of the application and then review the code.
Please note: The .Net Framework 2.0 is needed for this application!
Using 'Goto Shrinkster'
Starting the executable, GotoShrinkster.exe, brings up the application.
It defaults to a starting position in the lower right corner of your screen.
It also remains on top of the other windows so it is quickly found when a Shrinkster code is mentioned during a podcast.
To use, enter a code in the text box, press the Go button or hit enter, and a new browser will start! If you entered a valid code, Shrinkster will quickly redirect you to the uncompressed link.
Example: Entering 'dpn'
into the utility and hitting enter takes you to a page on
Scott Hanselman's blog. Scott's weekly talk shows use Shrinkster codes frequently.
The Code
From the screen shots you can see that the application is small and relatively straight forward. On the Windows Form, a ToolStrip contains just three items, a ToolStripLabel, a ToolStripTextBox, and a ToolStripButton.
The ToolStripTextBox is configured to take a maximum of 50 characters. Since the Shrinkster codes are fairly small, this should be sufficient.
The ToolStripButton (the Go button) will cause the application to launch a new browser if you have entered something into the ToolStripTextBox.
The code that is executed is the LetsGo method, which uses a WebBrowser control to launch IE.
/// <summary>
/// See if we have a code to use, and if so, build the URL and head off.
/// </summary>
private void LetsGo()
{
if (browserCode.Text.Trim().Length > 0)
{
WebBrowser wb = new WebBrowser();
wb.Navigate(BuildUrl(), true);
wb = null;
browserCode.Text = "";
this.Focus();
browserCode.Focus();
}
} //ends LetsGo
/// <summary>
/// Build the full url with the code entered from the app.
/// Note: Normally I don't like to hard code things like this url but
/// due to the nature of the utility I didn't want to have a config
/// file, registry entry, etc on the client.
/// </summary>
/// <returns>URL</returns>
private string BuildUrl()
{
return "http://www.shrinkster.com/" + browserCode.Text.Trim();
} //ends BuildUrl
Pressing enter while in the ToolStripTextBox will also trigger the launch sequence.
To do this, the application monitors your key presses by overriding the inherited ProcessCmdKey method, looking for 'enter.' The overridden method looks like:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
//if you hit enter while in the text box then lets go
if (keyData == Keys.Enter && this.ActiveControl != null)
{
LetsGo();
}
return base.ProcessCmdKey(ref msg, keyData);
} //ends ProcessCmdKey
Conclusion
I created this utility to have a small footprint on the screen since I'm usually doing multiple other things while listening to a podcast. By having it on top all the time I can quickly enter in a Shrinkster code. I think you'll find this utility usefull and a time saver.
Revision History
2007-02-09 Original submission.