欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-03-07 15:07:48
vbscript 语法简单 强大 但是功能上明显不足 需要第三方的控制 e.g. com 组件来扩展其功能. vbsedit 安装完之后就可以在安装目录下发现 免费提供的...

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) —

相关标签: VBSEdit vbs-toolkit