Turn to HTAs to give your scripts that Windows-like feel, without the programming overhead.
Ready for your Scripting Answers? This issue, I'll show you how to make
your HTML Applications (HTAs, which are scripts that look like professional
Windows apps) cooler and more professional-looking. If you're totally
new to HTAs, hop over to the Forums on www.ScriptingAnswers.com
we've got a whole discussion on the topic.
As you may know, an HTA is a special HTML page that includes both HTML
formatting codes as well as your VBScript. It's a sort of low-end Windows
application or high-end script depending on how you look at it, and it
offers the ability to have a robust graphical user interface, which VBScript
The key to it all is the special HTA tag which is embedded at the start
of an HTA file:
Applicationname = "MyApplication"
Most scripters will use a simple HTA that meets the minimum requirements;
get more complicated, though, and you can gain some real control over
what your HTAs look like and how they perform.
For more scripting help, check out Don's work at http://www.scriptinganswers.com.
Plus, don't forget "Mr.
Script" columnist Chris Brooke over at http://redmondmag.com/columns/mcsescripting/.
And, let us know how you like Don's new column by
e-mailing us at [email protected]
with "Scripting Answers column" on the subject
line of your message and I'll send 3 lucky winners from
all respondents a nifty MCPmag.com baseball cap.
Contest ends December 16; winners will be announced
in December 20th column.
This simple tag uses two attributes: One to define the application's
name, and another to turn off the Internet Explorer scroll bars (since
most Windows applications don't have them, this leads to a more professional
look). But there are bunches more attributes you can add:
- Border: Set to thick, dialog, none or thin to define the window border
- Caption: Set to no to turn off the title bar and title bar buttons;
use yes to keep them.
- Contextmenu: Set to no to suppress the normal IE right-click menus.
- Icon: Provide a path to an ICO file to specify a custom system menu
- Innerborder: Set to yes to display a 3D inner border, or no to do
- Maximizebutton: Control the appearance of this button by setting to
yes or no.
- Minimizebutton: Set to no to hide the button (and remove the capability
to minimize the window); set to yes to show it.
- Navigable: Set to yes to allow any hyperlinks to open in the same
window; set to no and hyperlinks will pop open a new IE window for browsing,
just like a "real" application.
- Scrollflat: If scroll bars are shown (set with the Scroll attribute),
set this to yes to make them appear flat or no to show the 3-D effect.
- Selection: Set to no to prevent text selection within the HTA window;
yes allows it.
- Showintaskbar: Set to yes to emulate "real" application
behavior and show a task bar button; set to no to emulate dialog box
behavior and hide the task bar button.
- Singleinstance: Want to ensure only one copy of your application runs
at a time? Set this to yes; set to no to allow multiple copies.
- Sysmenu: Set to no to hide the title bar system menu; set to yes to
- Windowstate: Set to minimize, normal, or maximize to control the initial
Use these attributes to define an HTA that looks like a system dialog
box, an application, or whatever you like. Suddenly your scripts will
look a lot more professional!
Don Jones is a multiple-year recipient of Microsoft’s MVP Award, and is Curriculum Director for IT Pro Content for video training company Pluralsight. Don is also a co-founder and President of PowerShell.org, a community dedicated to Microsoft’s Windows PowerShell technology. Don has more than two decades of experience in the IT industry, and specializes in the Microsoft business technology platform. He’s the author of more than 50 technology books, an accomplished IT journalist, and a sought-after speaker and instructor at conferences worldwide. Reach Don on Twitter at @concentratedDon, or on Facebook at Facebook.com/ConcentratedDon.