bkemmler Posted June 4, 2005 Share Posted June 4, 2005 (edited) This is a converter for a VBScript (5.6) to AutoIt (3.1.1) converter.i hope it is useful.There are many thinks to add at the moment.To test it you need all attach files.Comments are welcome.Version 0.4- Fixing error message in GUI- Workaround for wscript.echo- Better handling of parenthesis for sub's- Implement ReDim- Set default destination file name in gui- Added some new commands in VATable.txt- Improvements for select constructsVersion 0.3- Added command line switch (vaconvert VBSCRIPTFILE)- Added Gui to select source and destination file (tahnks to gafrost)- Better handlung for prodedure calls- Fixing other errors (e.g. endless loop)Version 0.2- Add some simple replace commands (VATable.txt)- Improve Select case - Find variables without Dim- Find Constants- Add List of VBCommands (VACommands.txt)Version 0.1- Better function handling- Added most VBScript functions- Include handlingVersion 0.01- First public releaseAdded v0.4 10.06.2005Added v0.3 08.06.2005Added v0.2 06.06.2005Added v0.1 05.06.2005Added v0.01 04.06.2005VAConvert.04.zip Edited June 10, 2005 by bkemmler meoit 1 Link to comment Share on other sites More sharing options...
SumTingWong Posted June 4, 2005 Share Posted June 4, 2005 This is the first public release (v0.02) of a VBScript (5.6) to AutoIt (3.1.1) converter.i hope it is useful.There are many thinks to add at the moment.To test it you need all attach files.Comments are welcome.<{POST_SNAPBACK}>Very nicely done! Link to comment Share on other sites More sharing options...
bkemmler Posted June 4, 2005 Author Share Posted June 4, 2005 can it goes from autoit to VB as well?because although I dont know vb I do know autoIT and VB is necessary for some things<{POST_SNAPBACK}>No it is only converting from VBScript to AutoIt.Everything you want to do with VBScript should be possible with AutoIt Link to comment Share on other sites More sharing options...
GaryFrost Posted June 5, 2005 Share Posted June 5, 2005 (edited) Thought it could use a little gui interface, this was quick and dirty expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.1 ; Author: Bernd Kemmler ; ; Script Function: ; Convert VBScript to AutoIt 3.1.1 ; ; Version 0.02 ; ---------------------------------------------------------------------------- ; To Do: ; o Special handling of: SELECT, Func Return, Class Blocks, Dim, Do loop, Redim, Function ; o GUI to select the source, destination ; o include handling ; ... ;Options #region Options #NoTrayIcon AutoItSetOption("MustDeclareVars", 1) AutoItSetOption("RunErrorsFatal", 0) AutoItSetOption("TrayIconHide", 1) ; Variable declarations #region Variables Global Const $strVersion = "0.02" Global Const $strMask = "#" Global Const $strRemark = "'" Global Const $strSpecial = ".,()<>=" Global $arrVBFile Global $arrVBFileMarked Global $arrAU3File Dim $Lbl_Source, $Lbl_Dest, $Btn_Source, $Btn_Dest, $Btn_Convert, $Btn_Exit, $msg #endregion ; Include files #region Includes #include <bk-array.au3> #include <bk-file.au3> #include <bk-string.au3> #include <array.au3> #include <math.au3> #endregion #region --- GuiBuilder code Start --- ; Script generated by AutoBuilder 0.5 Prototype #include <GuiConstants.au3> GuiCreate("Convert VBScript to AutoIt 3.1.1++", 500, 208) $Lbl_Source = GuiCtrlCreateLabel("Source File", 30, 30, 400, 20) $Lbl_Dest = GuiCtrlCreateLabel("Destination File", 30, 70, 400, 20) $Btn_Source = GuiCtrlCreateButton("Select...", 420, 20, 70, 30) $Btn_Dest = GuiCtrlCreateButton("Select...", 420, 60, 70, 30) $Btn_Convert = GuiCtrlCreateButton("Convert", 154, 130, 70, 30) $Btn_Exit = GuiCtrlCreateButton("Exit", 264, 130, 70, 30) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit ExitLoop Case $msg = $Btn_Source GUICtrlSetData($Lbl_Source,FileOpenDialog ( "Select VBS Source File", ".", "VBS (*.vbs)" , 3 )) Case $msg = $Btn_Dest GUICtrlSetData($Lbl_Dest,FileOpenDialog ( "Select Au3 Dest File", ".", "AutoIt (*.au3)" )) Case $msg = $Btn_Convert Convert(GUICtrlRead($Lbl_Source),GUICtrlRead($Lbl_Dest)) EndSelect WEnd Exit #endregion --- GuiBuilder generated code End --- Func Convert($Source, $Dest) ReadVBFile($Source) MarkSpecialParts() ReplaceSimpleCommands() ChangeVariables() WriteAU3File($Dest) EndFunc Edited June 5, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
bkemmler Posted June 5, 2005 Author Share Posted June 5, 2005 Thanks for the GUI. I will include it in the next version. At the moment it is faster for the testing to just use test.vbs. Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted June 5, 2005 Share Posted June 5, 2005 Wow am I slow, I just realized that i need the commands.txt file as well Also, are there plans to automatically change the variable into the $variable_name format? Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
steve8tch Posted June 6, 2005 Share Posted June 6, 2005 Can I throw a spanner in to the works..... I just found a relatively simple vbs script to do a test. The converted script still needs alot of work done to make it usable in Aut3. Am I doing it right! I wasn't too sure what I was supposed to do with the commands.txt Here is my test vbs script - can you check if it works OK for you. expandcollapse popup' FreeSpace.vbs, Version 1.00 ' Display free disk space for all local drives. ' ' Written by Rob van der Woude ' http://www.robvanderwoude.com ' Check command line parameters Select Case WScript.Arguments.Count Case 0 ' Default if none specified is local computer (".") Set objWMIService = GetObject( "winmgmts://./root/cimv2" ) Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem", , 48 ) For Each objItem in colItems strComputer = objItem.Name Next Case 1 ' Command line parameter can either be a computer name ' or "/?" to request online help strComputer = Wscript.Arguments(0) if InStr( strComputer, "?" ) > 0 Then Syntax Case Else ' Maximum is 1 command line parameter Syntax End Select Display( strComputer ) WScript.Quit(0) Function Display( strComputer ) strMsg = vbCrLf & "Name:" & vbTab & "Drive:" & vbTab & "Size:" & _ vbTab & "Free:" & vbTab & "% Free:" & vbCrLf & "=====" & _ vbTab & "======" & vbTab & "=====" & vbTab & "=====" & _ vbTab & "=======" & vbCrLf On Error Resume Next Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" ) If Err.Number Then WScript.Echo vbCrLf & "Error # " & CStr( Err.Number ) & _ " " & Err.Description Err.Clear Syntax End If On Error GoTo 0 ' Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk where MediaType=12",,48) Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk where DriveType=3",,48) For Each objItem in colItems strMsg = strMsg & strComputer & vbTab & _ objItem.Name & vbTab & _ CStr( Int( 0.5 + ( objItem.Size / 1073741824 ) ) ) & _ vbTab & _ CStr( Int( 0.5 + ( objItem.FreeSpace / 1073741824 ) ) ) & _ vbTab & _ CStr( Int( 0.5 + ( 100 * objItem.FreeSpace / objItem.Size) ) ) & _ vbCrLf Next WScript.Echo strMsg End Function Sub Syntax strMsg = vbCrLf & "FreeSpace.vbs, Version 1.00" & vbCrLf & _ "Display free disk space for all local drives." & vbCrLf & _ vbCrLf & _ "Usage: CSCRIPT FREESPACE.VBS [ computer_name ]" & _ vbCrLf & vbCrLf & _ "Where: " & Chr(34) & "computer_name" & Chr(34) & _ " is the name of a WMI enabled computer on the network" & _ vbCrLf & vbCrLf & _ "Written by Rob van der Woude" & vbCrLf & _ "http://www.robvanderwoude.com" & vbCrLf WScript.Echo strMsg WScript.Quit(1) End Sub Thanks Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted June 6, 2005 Share Posted June 6, 2005 I was working on my own script, and the WScript.Echo wasn't being translated...I don't know if it was just my script or... Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
bkemmler Posted June 6, 2005 Author Share Posted June 6, 2005 Can I throw a spanner in to the works..... I just found a relatively simple vbs script to do a test.The converted script still needs alot of work done to make it usable in Aut3.Am I doing it right!I wasn't too sure what I was supposed to do with the commands.txtHere is my test vbs script - can you check if it works OK for you.Thanks<{POST_SNAPBACK}>You are right. With this kind of script it will have problems. The actual version needs DIM's for the variables. Link to comment Share on other sites More sharing options...
bkemmler Posted June 6, 2005 Author Share Posted June 6, 2005 I was working on my own script, and the WScript.Echo wasn't being translated...I don't know if it was just my script or...<{POST_SNAPBACK}>There is no command like WScript.Echo in AutoIt. And if you do not want to use WSH, it is not a good idea to use the WScript object. Link to comment Share on other sites More sharing options...
bkemmler Posted June 6, 2005 Author Share Posted June 6, 2005 Wow am I slow, I just realized that i need the commands.txt file as well Also, are there plans to automatically change the variable into the $variable_name format?<{POST_SNAPBACK}>If you use the DIM command in VBScript it is working already. Link to comment Share on other sites More sharing options...
bkemmler Posted June 6, 2005 Author Share Posted June 6, 2005 Version 0.2 Release Link to comment Share on other sites More sharing options...
ptrex Posted June 6, 2005 Share Posted June 6, 2005 Hello, Downloaded the new version and ran it with AutoIT version 3.1.1.41 Alpha. But nothing happenes ? When running the VACONVERT.AU3 I expected a Gui to come up, is that correct ? Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted June 6, 2005 Share Posted June 6, 2005 (edited) i believe right now it only converts a file called 'test.vbs' located in the scripts directory. As for WScript.Echo, can't you just do 'MsgBox(0, "", $variable)'? Edited June 6, 2005 by MSLx Fanboy Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
ptrex Posted June 7, 2005 Share Posted June 7, 2005 This script might be useful. But untill there is no readme file, explaining on how to use it, it is NOT useful. Hopefully more help is on the way. Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
bkemmler Posted June 8, 2005 Author Share Posted June 8, 2005 This script might be useful. But untill there is no readme file, explaining on how to use it, it is NOT useful.Hopefully more help is on the way.<{POST_SNAPBACK}>There is a gui now available. I hope this helps. Link to comment Share on other sites More sharing options...
bkemmler Posted June 8, 2005 Author Share Posted June 8, 2005 Version 0.3 can be downloaded Link to comment Share on other sites More sharing options...
ptrex Posted June 9, 2005 Share Posted June 9, 2005 @bkemmler Thanks for the new version. Now help file needed anymore since the GUI runs OK. I tested a VBscript which should show the OS version of your system. The converion was done 95 % OK. Which is a pretty good job. The only thing you need to build in into you conversion is the translation from Wscript.Echo -> Msgbox to show the output. At the moment there is no output after the conversion. Vbscript : 'Returns the name and version number of the operating system installed on a computer. strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems Wscript.Echo objOperatingSystem.Caption & " " & _ objOperatingSystem.Version Next AuITScript: ;Returns the name and version number of the operating system installed on a computer. $strComputer = "." $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colOperatingSystems = $objWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") For $objOperatingSystem in $colOperatingSystems ;VA Wscript.Echo $objOperatingSystem.Caption & " " & _ $objOperatingSystem.Version() Next SEE COMMENT;VA where there has been no translation done !! This should have been : Msgbox(0, "VBScript to AutoIt Converter v0.3", $objOperatingSystem.Caption & " " & $objOperatingSystem.Version()) I hope this feedback helps you improving. It only needs a little bit extra tweaking. Keep up the good work !! Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
GaryFrost Posted June 9, 2005 Share Posted June 9, 2005 Personally I would rather the WScript.Echo get converted to ConsoleWrite. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
ptrex Posted June 9, 2005 Share Posted June 9, 2005 @gafrost@bkemmlerThe explanation in the help, of the ConsoleWrite is :Writes data to a stream that text editors can SOMETIMES read.- The first reason whu this should not be shosen is of the SOMETIMES possibility. If you like this option VBscript has an other command that produces output to console. This command should than be translated to ConsoleWrite.- The second reason not to choose this is, that not an exact conversion of how the behaviour was in VBscript Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now