没有合适的资源?快使用搜索试试~ 我知道了~
首页WSH and VBScript - Advanced Windows Script Host Developers Guide (2003)
WSH and VBScript - Advanced Windows Script Host Developers Guide...
需积分: 9 56 浏览量
更新于2023-03-03
评论
收藏 2.48MB PDF 举报
WSH and VBScript - Advanced Windows Script Host Developers Guide (2003) ,非常有价值的资料
资源详情
资源评论
资源推荐

© G. Born – Advanced Windows Script Host Developer's Guide
Günter Born
Advanced
Windows Script Host
Developer's Guide

II
© G. Born – Advanced Windows Script Host Developer's Guide
Günter Born
Advanced Windows Script Host Developer's Guide
This is the English version of parts of my book:
"Inside Windows Scripting Host",
Microsoft Press Germany, 2002
ISBN 3-86063-495-X
Published by Günter Born
Copyright © 2003 by Günter Born
www.borncity.com
All rights reserved. No part of the contents of this document may be reproduced or transmitted in
any form or by any means without the written permission of the author/publisher.
Disclaimer
The materials, sample code, and files in this text and from referenced sources are provided AS IS
WITHOUT WARRANTY OF ANY KIND AND ARE PROVIDED WITHOUT ANY IMPLIED
WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY. Use of the materials
and code is to be undertaken entirely at your risk, and the results that may be obtained from that
use are dependent on the user.

III
© G. Born – Advanced Windows Script Host Developer's Guide
G. Born:
Advanced Windows Script Host Developer's Guide
Introduction XXIII
The story about this book?.....................................................................................................XXIII
How to use this book?........................................................................................................... XXIV
A few other remarks ...............................................................................................................XXV
1
Tools and Techniques 15
A few tips to edit scripts ............................................................................................................. 15
How to create a script? 15
Edit existing script files? 18
Define your own Edit script command 18
Script Editors .............................................................................................................................. 20
EditPlus 20
PrimalSCRIPT script editor 21
Using Microsoft Script Editor 21
Other editors 25
The OLE/COM Object Viewer................................................................................................... 26
Using the Object Browser........................................................................................................... 27
Debugging WSH scripts ............................................................................................................. 31
Using a WSH IDE to execute and debug scripts 31
2
User Input in scripts 33
User input in VBScript ............................................................................................................... 33
User input in JScript ................................................................................................................... 36
JScript-user input using a second script 36
Internet Explorer for JScript user input....................................................................................... 39
Implementing an InputBox function in HTML 40
Call the function within the HTML document 41
The InputBox implementation for JScript 42
An InputBox ActiveX control..................................................................................................... 48
3
Using forms 51
User Forms with Internet Explorer ............................................................................................. 51
Creating a Dialog using showModalDialog 51
Using Internet Explorer for dialogs 56
Creating Forms using Internet Explorer...................................................................................... 59
The HTML code for the form 59

IV
© G. Born – Advanced Windows Script Host Developer's Guide
DHTML code to control your form 61
A WSH script to use the form 65
A JScript WSH script to access the form 70
Form input using a CallBack function........................................................................................ 72
Using ActiveX controls as forms................................................................................................ 75
Using an ActiveX control for an about dialog box 76
Using the About dialog from a WSH script 82
Using a form for user input......................................................................................................... 84
Creating the form using VB 5 CCE 84
How to define global variables to keep user input values? 89
How to implement the form handling methods? 89
How to use the ActiveX control in a WSH script? 91
Using the form in JScript 92
Implementing a password input dialog ....................................................................................... 93
A WSH script using the password input 95
4
ActiveX controls programming 99
VB 5 CCE the basics .................................................................................................................. 99
What is VB 5 CCE? 99
Create a new ActiveX-Project 101
Introduction into VB 5 CCE ..................................................................................................... 102
About projects, classes, modules and properties 102
The code window 105
The properties window 107
Inserting controls into a Form 109
Creating an OCX file................................................................................................................ 110
Create an install file for an ActiveX control 113
How to get information about objects?..................................................................................... 114
Create an object description for the object browser 115
A project sample ....................................................................................................................... 116
ActiveX samples....................................................................................................................... 119
Implementing the WSHKeyExist1 method................................................................................ 119
A Wait method for Scripts 123
A method to play sounds within a script 129
WSHShell- and WSHAppActivate methods............................................................................... 134
Implementing the WSHShell method 135
Implementing the WSHAppActivate method 137
Testing WSHShell and WSHAppActivate 139
The SendKeys problem ............................................................................................................. 140

V
© G. Born – Advanced Windows Script Host Developer's Guide
Implementing a WSHSendKeys method.................................................................................... 143
Remarks about the WSHSendKeys method 143
Remarks about the WSHSendKeys implementation 146
Sample 1: Launch and terminate Calc.exe 147
Sample 2: Manipulating two applications using WSHSendKeys 150
Sample 3: Clipboard handling using WSHSendKeys 153
Using WSHSendKeys to create a new user account .................................................................. 157
How to handle windows?.......................................................................................................... 165
The WSHFindWindow method 166
The WSHIsWindow method 167
The WSHIsIconic method 168
The WSHShowWindow method 170
The WSHSetForegroundWindow method 173
The WSHMoveWindow method 174
The WSHFlashWindow method 175
Sample 1: Manipulate a window 177
Sample 2: A moving and flashing window 179
Shutdown Windows 95/98 using a script.................................................................................. 183
A script using the WSHExitWindows method 185
5
WSH and Microsoft Office 189
Using Microsoft Excel.............................................................................................................. 189
The Excel object model 189
A sample to access Excel 190
Set the window properties 191
The implementation in VBScript 193
An implementation in JScript 194
Create an Excel worksheet and add the content 196
The VBScript implementation 199
The JScript Implementation 202
Writing WSH information into a worksheet 204
The VBScript Implementation 206
The JScript implementation 209
Load an Excel XLS file and read the data 212
Implementing the sample in VBScript 214
An implementation in JScript 215
Importing a CSV file in Excel 217
How to import CSV files into several columns? 220
Using Microsoft Word.............................................................................................................. 226
剩余431页未读,继续阅读


















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0