vbs-toolkit VBSEdit 提供 免费的COM组件

所属分类: 脚本专栏 / vbs 阅读数: 1050
收藏 0 赞 0 分享

VBSCRIPT 语法简单 强大 但是功能上明显不足 需要第三方的控制 e.g. COM 组件来扩展其功能. VBSEDIT 安装完之后就可以在安装目录下发现 免费提供的 COM 组件 vbs toolkit.

下载 VBSEDIT 工具

32 位 DLL: vbsedit32 60 VBSEdit 提供
64 位 DLL: vbsedit64 61 VBSEdit 提供

注册组件

注册组件需要管理员权限. 可以运行下面命令分别注册 32, 64 位的VBSEDIT 工具箱.

regsvr32 vbsedit32.dll
regsvr32 vbsedit64.dll

注销的时候则需要 加 /u 参数

regsvr32 /u vbsedit32.dll
regsvr32 /u vbsedit64.dll

提供了一些方便的功能扩展 比如剪贴板.

Set toolkit = CreateObject("VbsEdit.Toolkit")
toolkit.PutClipboardText "Hello World" 
WScript.Echo toolkit.GetClipboardText() 

CLIPBOARD OPERATIONS

GetClipboardText method

1、获取剪切板中的文本内容

Set toolkit = CreateObject("VbsEdit.Toolkit")
WScript.Echo toolkit.GetClipboardText() 

PutClipboardText method

2、将指定内容设置到剪切板中

Set toolkit = CreateObject("VbsEdit.Toolkit")
toolkit.PutClipboardText "Hello World"

运行后就将剪切板的数据设置为 Hello World

DIALOG BOXES

OpenFileDialog method
Prompt the user to open a file
toolkit.OpenFileDialog ([initialFolder,[filters,[multiselect,[title]]]])

'Opens a single file
Set toolkit = CreateObject("VbsEdit.Toolkit")
files=toolkit.OpenFileDialog("c:\scripts\","Text Files (*.txt)|*.txt",False,"Open a text file")
If UBound(files)>=0 Then
 WScript.Echo files(0)
Else
 Wscript.Quit
End If
 
'Opens multiple files
Set toolkit = CreateObject("VbsEdit.Toolkit")
files=toolkit.OpenFileDialog("c:\scripts\","Text Files (*.txt)|*.txt",True,"Open a text file")
If UBound(files)>=0 Then
 For Each filepath In files
  WScript.Echo filepath
 Next
Else
 Wscript.Quit
End If

上面的代码就是打开只可以输入一个文件的对话框,第二段就是可以选择多个文件的对话框

SaveFileDialog method

Prompt the user to save a file
toolkit.SaveFileDialog ([initialFolder,[initialFilename,[filters,[title]]]])

Set toolkit = CreateObject("VbsEdit.Toolkit")
filepath = toolkit.SaveFileDialog("c:\scripts","test.txt","Text Files (*.txt)|*.txt")
 
If Not(IsNull(filepath)) Then
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set objFile = objFSO.CreateTextFile(filepath,True)
 objFile.WriteLine Date
 objFile.Close
Else
 Wscript.Quit
End If

上面的代码就是另存为 文本文件对话框

SelectFolder method

Prompt the user to select a folder
toolkit.SelectFolder ([initialDir,[title]])

Set toolkit = CreateObject("VbsEdit.Toolkit")
myfolder=toolkit.SelectFolder("c:\scripts\","Please select a folder")
 
If Not(IsNull(myfolder)) Then
 WScript.Echo myfolder
Else
 Wscript.Quit
End If

上面的就是浏览文件夹对话框

ENUMERATING WINDOWS

TopLevelWindows method
Enumerates top level windows

Set toolkit = CreateObject("VbsEdit.Toolkit")
For each window in toolkit.TopLevelWindows()
 WScript.Echo window.WindowTitle
 WScript.Echo window.ProcessId
Next

枚举顶级窗口

Window object

ClassName
Retrieves the name of the class to which the specified window belongs.

WindowTitle
Retrieves the title of the specified window's title bar or the text of the control if the specified window is a control.

DlgCtrlID
Retrieves the identifier of the specified control.

Height
Retrieves the height of the specified window.

Width
Retrieves the width of the specified window.

X
Retrieves the X coordinate of the upper-left corner of the specified window.

Y
Retrieves the Y coordinate of the upper-left corner of the specified window.

IsVisible
Determines the visibility state of the specified window.

ProcessId
Retrieves the identifier of the process that created the specified window.

Click method
Sends a mouse click event to the specified window.
window.Click ([offsetX ,[offsetY]])
If offsetX and offsetY are not specified, the event is sent into the middle of the window.

SendText method
Sends text to the specified window.
window.SendText text

ChildWindows method
Enumerates the child windows that belong to the specified parent window.

–EOF (The Ultimate Computing & Technology Blog) —

更多精彩内容其他人还在看

VBS实现截图功能

本文给大家分享了下2种通过VBS实现截图功能的代码,第一个是纯VBS实现,第二种方法是通过把简短的第三方工具集合到VBS脚本来实现更加丰富的功能。
收藏 0 赞 0 分享

VBS中Run和Exec的区别

这篇文章主要介绍了VBS中Run和Exec的区别,需要的朋友可以参考下
收藏 0 赞 0 分享

VBS获取GZIP压缩的HTTP内容的实现代码

这篇文章主要介绍了VBS获取GZIP压缩的HTTP内容的实现代码,需要的朋友可以参考下
收藏 0 赞 0 分享

VC中实现文字竖排的简单方法(推荐)

下面小编就为大家带来一篇VC中实现文字竖排的简单方法(推荐)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

对一个vbs脚本病毒的病毒原理分析

这篇文章主要介绍了对一个vbs脚本病毒的病毒原理分析的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享

vbs判断磁盘类型和检测硬盘剩余空间的实现代码

这篇文章主要介绍了vbs判断磁盘类型和检测硬盘剩余空间的实现代码,需要的朋友可以参考下
收藏 0 赞 0 分享

VBS调用WMI遍历搜索硬盘文件并计数的方法

这篇文章主要介绍了VBS调用WMI遍历搜索硬盘文件并计数的方法,需要的朋友可以参考下
收藏 0 赞 0 分享

vbs 查找硬盘分区中指定扩展名文件的实现代码

vbs 用于查找硬盘所有分区中指定扩展名文件的代码,有需要的朋友可以参考下。挺实用的一段代码,用来深入学习vbs,确实不错
收藏 0 赞 0 分享

vbs Size 属性使用介绍(获取文件大小)

为大家介绍vbs属性之size属性,供大家学习参考。Size 属性 对于文件,返回指定文件的字节数;对于文件夹,返回该文件夹中所有文件和子文件夹的字节数
收藏 0 赞 0 分享

vbs获取当前路径的代码

有时候我们需要获取执行当前vbs的路径,那么就可以参考下面的代码,一般用来可以删除自身等操作
收藏 0 赞 0 分享
查看更多