User Interaction with Common Dialogs in WSH
(Page 1 of 4 )
As you progress into more detailed and more powerful code, you will find yourself focusing more and more on how your scripts appear to your users. Using common Windows dialog boxes will give your script a familiar, comfortable feel while appearing more like a fully functional application.
You've all seen the classic File Open and File Save dialog boxes in Windows. These standard dialogs are provided by the Common Dialogs Control that ships with Windows. Updates are made available via subsequent releases of the Visual Basic runtime environment and some Microsoft applications.
The Common Dialogs control is housed in the comctl32.dll library in your System32 directory. It is a registered component and is therefore made available to any application in the Windows environment.
As with any object, you can connect to the Common Dialogs control and use any of its available methods. In a standard programming language, such as Visual Basic or C++, this is a fairly simple task. However, it's not quite so simple in WSH.
Take the time to read this article slowly and thoroughly. WSH does not have native support for Common Dialogs. Whether the lack of support was intentional or a mere oversight is mostly irrelevant. The fact remains that the normal conditions that scripting was designed for have no real need for Common Dialogs.
But as is generally the case with programming technologies, the uses for scripting have evolved far beyond their intended purpose and, thus, the interest in Common Dialogs implementation has been born.
Please keep in mind that due to the nature of the examples that follow, they may not work in all situations or under every condition. These are all workarounds! While I will be making the attempt to provide code that should work, it's not possible for me to accurately forecast every scenario that may arise.
One final suggestion before we dive into things: if you are interested in applying a GUI to your scripts in an effort to make them look like real applications, you may want to consider the use of HTML applications.
HTAs are a scripting technology that allows you to house code in standalone web pages. This allows you to design a sort of UI with the use of forms and other web elements in full HTML and CSS. You may find this a more suitable solution.
Next: Accessing the Common Dialog control directly >>
More Windows Scripting Articles
More By Nilpo/Developer Shed Staff Writer