Jump to content

Converting VBS to Autoit


Recommended Posts

Hello,
Sharing a way to convert a VBS script to Autoit.
Below is a script that creates a text file in both languages.

'VBS Code
Function Main() 
    Dim Stuff
    Stuff = "Rodrigo" 
    Dim myFSO
    Dim WriteStuff 
    myFSO = CreateObject("Scripting.FileSystemObject")
    WriteStuff = myFSO.OpenTextFile("C:\Support\yourtextfile.txt", 8, True) 
    WriteStuff.WriteLine(Stuff)
    WriteStuff.Close() 
End Function
;Autoit
Func Main()
    Dim $Stuff
    $Stuff = "Rodrigo" 
    Dim $myFSO
    Dim $WriteStuff 
    $myFSO = ObjCreate("Scripting.FileSystemObject")
    $WriteStuff = $myFSO.OpenTextFile("C:\Support\yourtextfile.txt", 8, True) 
    $WriteStuff.WriteLine($Stuff)
    $WriteStuff.Close()
EndFunc

While in VBS to declare a variable you must put Dim or Set and the name of the variable, in Autoit just put the symbol $

VBS: Dim Stuff
Autoit: Dim $ Stuff or just $ Stuff
  
For objects
VBS: CreateObject
Autoit: ObjCreate

Link to post
Share on other sites

I'm sure there is more effort needed to convert a VBS to AutoIt.
By translating line by line you are overcomplicating the AutoIt code.
I would write AutoIt this way:

;Autoit
Func Main()
    Local $sStuff = "Rodrigo" 
    FileWriteLine("C:\Support\yourtextfile.txt", $sStuff)
EndFunc

So what is the goal of your post?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites
  • Moderators

@rcn3t0 as you're seeing from the comments, you may want to rethink all of your "examples". Everyone gets being new and wanting to share, and we welcome that on the forum. But it is worth ensuring that what you are sharing is worthwhile. In this case, as has been pointed out to you, the value of AutoIt comes not from being able to run VBScript code but from being able to do the same tasks better. If you spend some time becoming familiar with the language you will doubtless be in a position to offer examples of greater value to the community.

"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 post
Share on other sites
17 hours ago, JLogan3o13 said:

@rcn3t0 as you're seeing from the comments, you may want to rethink all of your "examples". Everyone gets being new and wanting to share, and we welcome that on the forum. But it is worth ensuring that what you are sharing is worthwhile. In this case, as has been pointed out to you, the value of AutoIt comes not from being able to run VBScript code but from being able to do the same tasks better. If you spend some time becoming familiar with the language you will doubtless be in a position to offer examples of greater value to the community.

Thanks for the feedback
I've seen posts of questions from people who needed a certain function and couldn't find how to do it in Autoit. But they found it in other languages and could not do the same in Autoit. And of these posts there was no return to the doubt put in question
I'm not a master of Autoit, far from it, but I've been developing in Autoit for almost 10 years and that doesn't make me a newbie in language, maybe in the forum, but I also know that your knowledge is way beyond mine.
I'm sure what I put here may be useful for someone, but if it makes no difference to others and is very complicated, please feel free to remove the post.
I always learned that knowledge never hurts

Link to post
Share on other sites

I searched the forum for "VBS translate" and only found some old and very old threads.
So coders on the forum either do not translate VBS to AutoIt very often or know how to.
If there were higher demand I would suggest a section in the AutoIt wiki - much easier to maintain ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites
51 minutes ago, water said:

I searched the forum for "VBS translate" and only found some old and very old threads.
So coders on the forum either do not translate VBS to AutoIt very often or know how to.
If there were higher demand I would suggest a section in the AutoIt wiki - much easier to maintain ;)

I didn't mention the forum, but the ones I had found were autoit forums on sites like iMasters, Autoit Brasil, itninja, among others besides the Autoit forum.
But you're right, demand seems to be low for that
Thanks for answering! 😄

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...