I spent a few hours a couple of days ago creating a plugin for Windows Live Writer that allows for easy screen captures. I've long been a huge fan of SnagIt from Techsmith and since SnagIt's capture functionality is available as a COM interface it's quite easy to expose the functionality in other applications. For example, I have SnagIt plugged into my Help Builder tool to provide for screen captures in the Help HTML content.
Blogging is kind of similar: image capturing is pretty vital and making the process directly integrated into Live Writer itself makes screen captures a real cinch. Combined with Live Writer's ability to send images directly to the Web site via HTTP image capturing and publishing has never been easier.
You can grab the plug in and code from:
Here's what the plugin looks like inside of Windows Live Writer:
When you click the Insert SnagIt button this dialog pops up which exposes most of the SnagIt capture options. Clicking Capture then goes off and uses SnagIt's native image capture functionailty (you know the red box to capture whatever capture mode selection you've made) to capture the image to file. You can optionally pop up the image editor and edit the image the same way as you can with native SnagIt use.
Settings are not saved, unless you click the Save Settings link, which stores the settings for later reuse. The idea is that you typically have a standard set of capture settings and these are restored each time you capture. You can also opt to not save the image locally. Live Writer actually makes a copy of each image you embed into a post so there's no need to hang on to captured images. The plugin writes out the file and then delay deletes the file if you have the Don't save image file option set to reduce file clutter on the local drive.
Creating a Live Writer Plugin
One of the nice things about Live Writer is the fact that you can very easily create plugins for it. You can download a Windows Live Writer SDK which provides fairly complete documentation and a few simple examples of how to plug into Live Writer. There are a host of different types of plugins you can create, although it looks like all plugins only address the content in the editor, not the overall operation of Writer. For example, as far as I can tell you can't override the HTTP communication or the actual messages that Writer sends when communicating with the server which would be very cool!
In any case creating an add-in that inserts content into the active blog post at the cursor position is very simple to create. The concept of this plug in is pretty simple:
- Create a class library project
- Add a reference to the WindowsLive.Writer.Api assembly to your project
- Implement the PlugIn API and handle the CreateContent method
- Create the SnagItAutomation object
- Bring up the Configuration Dialog that configures the object
- Run the screen capture
- Retrieve the filename that the capture writes to disk
- Insert the image as an <img> tag into the blog post
At the highest level the implementation of Writer Content plugin is quite simple:
"SnagIt Screen Capture",
ImagePath = "Images.snagit.png",
PublisherUrl = "http://www.west-wind.com/tools/SnagitLiveWriterPlugin.aspx",
Description = "Embeds a screen capture image from SnagIt.")]
[InsertableContentSource( "SnagIt Screen Capture" )]
public class SnagitScreenCapturePlugin : ContentSource
public override DialogResult CreateContent(IWin32Window dialogOwner, ref string newContent)
DialogResult dr = DialogResult.OK;
// *** Result Output file captured
string OutputFile = null;
SnagItAutomation SnagIt = SnagItAutomation.Create();
SnagIt.ActiveForm = Form.ActiveForm;
SnagItConfigurationForm ConfigForm = new SnagItConfigurationForm(SnagIt);
if (ConfigForm.ShowDialog() == DialogResult.Cancel)
OutputFile = SnagIt.CaptureImageToFile();
catch (Exception ex)
MessageBox.Show("Failed to capture image:\r\n\r\n" + ex.Message,
"SnagIt Capture Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
// *** Just embed the image
newContent = @"<img src='file:///" + OutputFile + "'>\r\n";
This is really all there's to the plugin portion of this particular plugin. All the work that happens for displaying the dialog and running the screen capture has really nothing to do with the plugin itself and is freestanding. The CreateContent method only cares about a result value that is the content HTML that is to be embedded into the page along with a DialogResult return value that indicates whether the operation was successful.
Other Posts you might also like