Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
The script shown in Listing 17.26 displays a message when the script starts and then displays a second message when the script ends. To create a more dynamic progress bar, you might want to do something to indicate the intermediate steps taken by the script. This can be as simple as displaying an asterisk (*) inside the browser window each time a service is retrieved and acted upon.
To create a dynamic progress indicator, you can use the WriteLn method to write information to the browser each time the script takes a particular action. As a result, you end up with a progress indicator similar to the one shown in Figure 17.4. Each time a service is retrieved and acted upon, another asterisk is added to the browser window.
Figure 17.4 Tracking Dynamic Script Progress by Using Internet Explorer
Tracking Dynamic Script Progress by Using Internet Explorer
Tip
Listing 17.26 contains a script that tracks script progress dynamically by using Internet Explorer. To carry out this task, the script must perform the following steps:
This query returns a collection consisting of all the services installed on the computer.
Listing 17.26 Tracking Dynamic Script Progress by Using Internet Explorer
|
|
If you are using Internet Explorer as a progress indicator, you might want to change the mouse pointer to an hourglass; this will help emphasize the fact that an operation is in progress. The mouse pointer can be configured by setting the cursor style to one of the values shown in Table 17.11.
Table 17.11 MousePointer Values
Value | Description |
---|---|
Crosshair | Simple crosshair. |
Default | Platform-dependent default cursor; usually an arrow. |
Hand | Hand with the first finger pointing up, as when the user moves the pointer over a link. |
Help | Arrow with question mark, indicating that help is available. |
Wait | Hourglass or watch, indicating that the program is busy and the user must wait. |
To change the mouse pointer, create a reference to the Internet Explorer Document object, and then set the cursor style to the appropriate value. For example, to display an hourglass while the script runs, use this code:
Set objDocument = objIE.Document objDocument.body.style.cursor =
"wait
"
To reset the cursor later in the script, use this code:
objDocument.body.style.cursor =
"default
"
Because it is often difficult to report absolute script progress (for example, to note that a script is 37 percent complete), an alternative approach is to display a pseudo progress indicator that simply informs the user that an operation is in progress. For example, in Figure 17.5 an instance of Internet Explorer is used to note that a script operation is in progress. Instead of tracking the percentage of the operation that is complete, however, the dialog box merely displays a ticking clock and the message, "Please wait while service information is retrieved. This might take several minutes to complete."
Figure 17.5 Tracking Script Progress by Using an Animated .GIF
Tracking Script Progress by Using an Animated .GIF
To use this type of progress indicator, start by creating an HTML file that includes both an animated GIF (for example, a ticking clock or a moving hourglass) and any other message you want the user to see. In your script, you create an instance of Internet Explorer and then use the Navigate method to open the HTML file. When the script completes, you then use the Quit method to close Internet Explorer.
Listing 17.27 contains a script that tracks script progress by displaying a pseudo progress indicator. This progress indicator is simply a Web page that includes an animated .GIF and a message asking the user to please wait. (The assumption is that you have already created this Web page.) To carry out this task, the script must perform the following steps:
Listing 17.27 Using an Animated .GIF as a Progress Indicator
|
|
Send us your feedback | « Previous | Next » |