Posted November 18, 2008 and filed under Technology    tags:  ,
hta

You're using HTAs right?

Whenever I have to write a script to automate some tasks I usually have to solicit input from the installer.  This can take the form of startup arguments, and external configuration file, or simply changing the script.  But I dislike all of these options because it's too easy to get an unpredictable result: a typo, missing character, or just plain ID-10-T error...  After all, I tell my customers that using scripts provides an simple, automated, efficient, and predictable way to perform a series of tasks. How can you have these benefits if it only takes a typo or missing argument to cause the scripts to go crazy?

So in the past couple of years I have been using the Microsoft HTML Applications to put a glossy front end to my scripts.  In case you haven't used the HTA engine to front your scripts then let me give you some more information right from the MSDN support pages:

HTML Applications (HTAs) are full-fledged applications. These applications are trusted and display only the menus, icons, toolbars, and title information that the Web developer creates. In short, HTAs pack all the power of Microsoft Internet Explorer—its object model, performance, rendering power, protocol support, and channel–download technology—without enforcing the strict security model and user interface of the browser. HTAs can be created using the HTML and Dynamic HTML (DHTML) that you already know.

Did you fully grok the implications of that last paragraph?  This is a powerful executable providing you the ability to have functionality similar to an Active Server Page without having to have a web server service.  Imagine being able to build a web page with inputs, buttons, and select tags, while leveraging VBScript and JavaScript as the code behind.  Additionally, you can dynamically add content to the html as your script is modified by the installer.  The main point here is that mshta.exe allows you to have the power of a web application with front-end scripting on all Windows computers.

For some people the power of HTAs is old news.  In fact, the Microsoft Developers Center has has been producing webcasts and sample code to help grow the community.  There is even a HTA Helpomatic to really help you get started.  But now it's time to move the power of HTA to the next level.

jquery

Let's talk about jQuery

Recently Microsoft announced that jQuery support would be included in the Visual Studio suite as an addition to the DOM developer.  This was an exciting announcement and I'm sure many developers are excited about this announcement.  But I was equally excited when I started thinking about how I could leverage the power of jQuery with my HTAs.  I imagined how easy it will be to bind to html objects, create additional tags, customize tags and properties.  Then I started thinking about all of those jQuery Plugins that could provide a slew of visual improvements and behaviors to my scripts.

The reason using jQuery in HTAs is so interesting to me is that one of the main constraints of using JavaScript in web pages (that being the amount of data that has to be transferred from the server to the client) has been lifted.  With your web pages you are always concerned with the amount of data that is being sent to the client causing a slow rendering.  With HTAs you don't have this issue.  The JavaScript and Plugins can be saved locally and included in a support folder for quick loading into your HTA.  After spending a few minutes looking through the jQuery Plugins list I came up with a couple Plugins that would provide an immediate improvement to my scripts: 

  • Collapsorz - Easily show/hide sections of your results with this handy Plugin
  • ToggleVal - Provide a watermark on your input fields so users know what the syntax should look like
  • Tablesorter - Add style and sorting to your result tables
  • Growl - Notification bubbles that can be configured to display for x number of seconds and then fade away

I am just about finished with an installation script for IIS 7.0 and plan on using several Plugins in my implementation.  I am also working on a JavaScript based HTA template that includes the above Plugins along with many common base functions that I tend to use on all of my scripts.  So stay tuned, and soon you can download these gems!

If you liked this article why not share it with others?

Kick it up to DotNetKicks.com

Comments

Add comment


(Will show your Gravatar icon)

biuquote
Loading