pete_wilde Posted September 23, 2019 Share Posted September 23, 2019 Hi Guys, I have read on previous threads about scripts which can convert Visual Basic code to AutoIT scripting (with varying degrees of success). Are any of these programs (or something newer) still around? I have a VB program that I would like to re-build in AutoIT. Unfortunately, I am not fluent in VB scripting, so to do it manually would mean learning VB first in order to understand what each bit of the code is trying to do in order to re-write it for AutoIT. My hope was to translate it little by little in order to eventually have it as an AutoIT script. Are there are good compiler/translators out there that users can recommend? Many thanks, Pete Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 23, 2019 Moderators Share Posted September 23, 2019 I have not seen any attempts at automatic conversion scripts in some time. Even the ones you have probably seen in the past were hit and miss (mostly miss) at best. As far as having to learn all of VBScript to convert, the languages are quite similar. I would suggest giving it a go yourself, rather than trusting to a conversion script and then not understanding if something doesn't work. If you hit any snags, feel free to post the vbscript here, along with a detailed description of what you're trying to do. Not only can forum members assist with syntax conversion, we may be able to suggest a better way to do things. pete_wilde 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
water Posted September 23, 2019 Share Posted September 23, 2019 Recently I had to convert a rather large VBS to AutoIt. I did the following replacements using the editor and about 90% of the conversion tasks has been done. Still manual editing is needed but went much faster. Quote ; VBS to AutoIt. Execute from first to last line "DIM " -> "Local $" Lines starting with "DIM " (now "Local $"): ", " -> ", $" "Set " -> "$" "'" -> ";" "call " -> "" "CreateObject("Scripting.FileSystemObject")" -> "" ; Delete this line "CreateTextFile" -> "" ; Replace with FileOpen "$obj" -> "$o" ; Hungary notation for object variables " = obj" -> " = $o" ; Hungary notation for object variables "With obj" -> "With $o" ; Hungary notation for object variables "$col" -> "$c" ; Hungary notation for object collection variables "$str" -> "$s" ; Hungary notation for string variables " = str" -> " = $s" ; Hungary notation for string variables "For Each obj" -> "For $o" " In col" -> " In $c" "If col" -> "If $c" "End " -> "End" ; End Select->EndSelect, End With->EndWith, End If->EndIf, End Function->EndFunc "Select Case " -> "Switch (" ; Add a ) at the end of this lines. Change closing "EndSelect" to "EndSwitch" "&H" -> "0x" ; Hex notation "len(" -> StringLen( ; Function name "Function " -> "Func " ; Replaces "Function " About how many lines of code do we talk? pete_wilde 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
pete_wilde Posted September 24, 2019 Author Share Posted September 24, 2019 (edited) Thanks guys - much appreciated 🙂 It's probably around 100-150 lines max, but mostly involves JSON calls as it contacts an API to send/receive data. This is the type of thing which I am struggling to convert Private Function SendSportsReq(ByVal jsonString As String) Dim request As HttpWebRequest = _ WebRequest.Create _ ($selected_url) Dim byteArray As Byte() = Encoding.UTF8.GetBytes(jsonString) Dim responseFromServer As String = "" Try request.Method = "POST" request.ContentType = "application/json" request.ContentLength = byteArray.Length request.Headers.Add("X-Application: 17shdgftekio45") request.Headers.Add("X-Authentication: " & ssoid) request.AutomaticDecompression = _ DecompressionMethods.GZip Or DecompressionMethods.Deflate request.ServicePoint.Expect100Continue = False request.Timeout = 2000 End Function Edited September 24, 2019 by pete_wilde update Link to comment Share on other sites More sharing options...
Danp2 Posted September 24, 2019 Share Posted September 24, 2019 You should take a look at the WinHTTP UDF. pete_wilde 1 Latest Webdriver UDF Release Webdriver Wiki FAQs 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