VBSedit (http://www.vbsedit.com) is a powerful, lightweight, commercial toolkit to edit, debug VBScript. It allows you to step by step executing VBScript and watch the variables. It also provides lots of scripting examples/code snippets. It also provides the scripting to executables.
VBScript is awesome, but it’s lacking a few things. The aim of this toolkit is to provide what is missing.
Download VBSedit Toolkit
32 bit DLL: vbsedit32
64 bit DLL: vbsedit64
How to register the toolkit
The toolkit is a dynamic linking library (DLL), it is located in Vbsedit installation folder (typically “c:\program files\vbsedit”). The 32 bit version is named vbsedit32.dll, the 64 bit version is named vbsedit64.dll.
The library must be registered in the system registry, it requires administrative rights.
To register it, you can type the following commands in a command window, or you can click Run from the Windows Start menu and type the commands:
regsvr32 vbsedit32.dll regsvr32 vbsedit64.dll
To unregister the toolkit, you should add /u parameter.
regsvr32 /u vbsedit32.dll regsvr32 /u vbsedit64.dll
Registration-free COM
If you convert your script into an executable, no registration is needed. However, you’ll have to ship the vbsedit32.dll or vbsedit64.dll files with your executable in the same folder.
Clipboard operations
GetClipboardText method
Retrieve Text From the clipoard
1 2 | Set toolkit = CreateObject("VbsEdit.Toolkit") WScript.Echo toolkit.GetClipboardText() |
Set toolkit = CreateObject("VbsEdit.Toolkit") WScript.Echo toolkit.GetClipboardText()
PutClipboardText method
Copy Text to the clipboard
1 2 | Set toolkit = CreateObject("VbsEdit.Toolkit") toolkit.PutClipboardText "Hello World" |
Set toolkit = CreateObject("VbsEdit.Toolkit") toolkit.PutClipboardText "Hello World"
Dialog boxes
OpenFileDialog method
Prompt the user to open a file
toolkit.OpenFileDialog ([initialFolder,[filters,[multiselect,[title]]]])
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | '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 |
'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]]]])
1 2 3 4 5 6 7 8 9 10 11 | 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 |
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]])
1 2 3 4 5 6 7 8 | 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 |
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
1 2 3 4 5 | Set toolkit = CreateObject("VbsEdit.Toolkit") For each window in toolkit.TopLevelWindows() WScript.Echo window.WindowTitle WScript.Echo window.ProcessId Next |
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) —
a WordPress rating system
Last Post: CI Server Failed After Upgrading Dotfuscator
Next Post: Use Flickr Uploader to Backup Photos Automatically