vbs-toolkit VBSEdit 提供 免费的COM组件
VBSCRIPT语法简单强大但是功能上明显不足需要第三方的控制e.g.COM组件来扩展其功能.VBSEDIT安装完之后就可以在安装目录下发现免费提供的COM组件vbstoolkit.
下载VBSEDIT工具
32位DLL:vbsedit3260VBSEdit提供
64位DLL:vbsedit6461VBSEdit提供
注册组件
注册组件需要管理员权限.可以运行下面命令分别注册32,64位的VBSEDIT工具箱.
regsvr32vbsedit32.dll
regsvr32vbsedit64.dll
注销的时候则需要加/u参数
regsvr32/uvbsedit32.dll
regsvr32/uvbsedit64.dll
提供了一些方便的功能扩展比如剪贴板.
Settoolkit=CreateObject("VbsEdit.Toolkit")
toolkit.PutClipboardText"HelloWorld"
WScript.Echotoolkit.GetClipboardText()
CLIPBOARDOPERATIONS
GetClipboardTextmethod
1、获取剪切板中的文本内容
Settoolkit=CreateObject("VbsEdit.Toolkit")
WScript.Echotoolkit.GetClipboardText()
PutClipboardTextmethod
2、将指定内容设置到剪切板中
Settoolkit=CreateObject("VbsEdit.Toolkit")
toolkit.PutClipboardText"HelloWorld"
运行后就将剪切板的数据设置为HelloWorld
DIALOGBOXES
OpenFileDialogmethod
Prompttheusertoopenafile
toolkit.OpenFileDialog([initialFolder,[filters,[multiselect,[title]]]])
'Opensasinglefile
Settoolkit=CreateObject("VbsEdit.Toolkit")
files=toolkit.OpenFileDialog("c:\scripts\","TextFiles(*.txt)|*.txt",False,"Openatextfile")
IfUBound(files)>=0Then
WScript.Echofiles(0)
Else
Wscript.Quit
EndIf
'Opensmultiplefiles
Settoolkit=CreateObject("VbsEdit.Toolkit")
files=toolkit.OpenFileDialog("c:\scripts\","TextFiles(*.txt)|*.txt",True,"Openatextfile")
IfUBound(files)>=0Then
ForEachfilepathInfiles
WScript.Echofilepath
Next
Else
Wscript.Quit
EndIf
上面的代码就是打开只可以输入一个文件的对话框,第二段就是可以选择多个文件的对话框
SaveFileDialogmethod
Prompttheusertosaveafile
toolkit.SaveFileDialog([initialFolder,[initialFilename,[filters,[title]]]])
Settoolkit=CreateObject("VbsEdit.Toolkit")
filepath=toolkit.SaveFileDialog("c:\scripts","test.txt","TextFiles(*.txt)|*.txt")
IfNot(IsNull(filepath))Then
SetobjFSO=CreateObject("Scripting.FileSystemObject")
SetobjFile=objFSO.CreateTextFile(filepath,True)
objFile.WriteLineDate
objFile.Close
Else
Wscript.Quit
EndIf
上面的代码就是另存为文本文件对话框
SelectFoldermethod
Prompttheusertoselectafolder
toolkit.SelectFolder([initialDir,[title]])
Settoolkit=CreateObject("VbsEdit.Toolkit")
myfolder=toolkit.SelectFolder("c:\scripts\","Pleaseselectafolder")
IfNot(IsNull(myfolder))Then
WScript.Echomyfolder
Else
Wscript.Quit
EndIf
上面的就是浏览文件夹对话框
ENUMERATINGWINDOWS
TopLevelWindowsmethod
Enumeratestoplevelwindows
Settoolkit=CreateObject("VbsEdit.Toolkit")
Foreachwindowintoolkit.TopLevelWindows()
WScript.Echowindow.WindowTitle
WScript.Echowindow.ProcessId
Next
枚举顶级窗口
Windowobject
ClassName
Retrievesthenameoftheclasstowhichthespecifiedwindowbelongs.
WindowTitle
Retrievesthetitleofthespecifiedwindow'stitlebarorthetextofthecontrolifthespecifiedwindowisacontrol.
DlgCtrlID
Retrievestheidentifierofthespecifiedcontrol.
Height
Retrievestheheightofthespecifiedwindow.
Width
Retrievesthewidthofthespecifiedwindow.
X
RetrievestheXcoordinateoftheupper-leftcornerofthespecifiedwindow.
Y
RetrievestheYcoordinateoftheupper-leftcornerofthespecifiedwindow.
IsVisible
Determinesthevisibilitystateofthespecifiedwindow.
ProcessId
Retrievestheidentifieroftheprocessthatcreatedthespecifiedwindow.
Clickmethod
Sendsamouseclickeventtothespecifiedwindow.
window.Click([offsetX,[offsetY]])
IfoffsetXandoffsetYarenotspecified,theeventissentintothemiddleofthewindow.
SendTextmethod
Sendstexttothespecifiedwindow.
window.SendTexttext
ChildWindowsmethod
Enumeratesthechildwindowsthatbelongtothespecifiedparentwindow.
–EOF(TheUltimateComputing&TechnologyBlog)—