Jump to content

VBScript to AutoIt Converter


Recommended Posts

Personally I would rather the WScript.Echo get converted to ConsoleWrite.

<{POST_SNAPBACK}>

The next release (v0.4) is converting it to a function which is writing the echo to a log file.

But if you want to use ConsoleWrite you just need to modify the VATable.txt file (beginning from v0.4).

Just change the line where you can find the text WScript.Echo:

WScript.Echo|ConsoleWrite|0|0|1|

If you want to use the MsgBox, you must write a wrapper arround MsgBox:

e.g.

Func _MyMsgBox($strText)
   MsgBox(0,"Some Text",$strText)
EndFunc

Save this wrapper in a Include file (e.g msg.au3) and change the line in the VATable.txt file like this:

WScript.Echo|_MyMsgBox|0|0|1|msg.au3

But keep in mind. WScript.Echo can be used from Version 0.4. It should be release tomorrow.

I hope i could help you.

Edited by bkemmler
Link to comment
Share on other sites

  • 3 months later...

Don't know if your still working on this as the last post date was "Jun 9 2005" but just incase, this is a sample of an output i got when using your script so it needs a little bit more yet

; ----------------------------------------------------------------------------
;
; VBScript to AutoIt Converter v0.4
;
; ----------------------------------------------------------------------------

#include <bk-logfile.au3>
#include <date.au3>

Const $SEC_IN_DAY = 86400
Const $ADS_UF_DONT_EXPIRE_PASSWD = &h10000
 
 $objUserLDAP = ObjGet _
  ("LDAP://CN=myerken,OU=management,DC=fabrikam,DC=com")
$intCurrentValue = $objUserLDAP.Get("userAccountControl")
 
If $intCurrentValue and $ADS_UF_DONT_EXPIRE_PASSWD Then
    _WriteLog ("The password does not $EXPIRE.")
Else
    $dtmValue = $objUserLDAP.PasswordLastChanged 
    _WriteLog ("The password was last changed on " & _)
        DateValue($dtmValue) & " at " & TimeValue($dtmValue) & @CRLF & _
            "The difference between when the password was last set" &  _
                "and today is " & int(_Now() - $dtmValue) & " days"
    $intTimeInterval = int(_Now() - $dtmValue)
  
     $objDomainNT = ObjGet("WinNT://fabrikam")
    $intMaxPwdAge = $objDomainNT.Get("MaxPasswordAge")
    If $intMaxPwdAge < 0 Then
        _WriteLog ("The Maximum Password Age is set to 0 in the " & _)
            "domain. Therefore, the password does not $EXPIRE."
    Else
        $intMaxPwdAge = (intMaxPwdAge/SEC_IN_DAY)
        _WriteLog ("The maximum password age is " & $intMaxPwdAge & " days")
        If $intTimeInterval >= $intMaxPwdAge Then
          _WriteLog ("The password has expired.")
        Else
          _WriteLog ("The password will $EXPIRE on " & _)
              DateValue($dtmValue + $intMaxPwdAge) & " (" & _
                  int(($dtmValue + $intMaxPwdAge) - _Now()) & " days from today" & _
                      ")."
        EndIf
    EndIf
EndIf

the issues are:

the second CONST statement Autoit doesn't like the Value

the _WriteLog lines that are wrapped but the close ")" is put on the first line instead of the last line

on this line the Variables intMaxPwdAge & SEC_IN_DAY weren't updated with $ :

$intMaxPwdAge = (intMaxPwdAge/SEC_IN_DAY)

The DateValue & TimeValue functions weren't converted

other than that your very close to having a fully functional converter

keep up the good work ;)

Edited by drak
Link to comment
Share on other sites

Hi,

I have changed a converted script a little, but it still does not work to sort an excel sheet as the vbscript does.

I think there is a bug in the "sort" call in AutoIt3; any way to tell before i post it to bugs?

Thanks, Randall

; ----------------------------------------------------------------------------

;

; VBScript to AutoIt Converter v0.4

;

; ----------------------------------------------------------------------------

Dim $oXL

Const $xlDescending = 2

Const $xlAscending = 1

Const $xlGuess = 0

Const $xlTopToBottom = 1

$oXL = ObjCreate("Excel.Application")

$oXL.Visible = 1

; BEGIN CALLOUT A

;$FilePath=@ScriptDir&"\book1.xls"

$FilePath="C:\Program Files\Au3PROGS\SciTe\book1.xls"

$oXL.Workbooks.Open($FilePath)

; END CALLOUT A

$oXL.Worksheets(1).Activate

$oXL.ActiveCell.CurrentRegion.Select()

; BEGIN CALLOUT B

;**********************************************************************

;* Excel Sort Method Syntax:

;* expression.Sort(Key1, Order1, Key2, Type, Order2, Key3, Order3,

;* Header, OrderCustom, MatchCase, Orientation, SortMethod)

;*

;* Notice that blank entries are supplied for Type (fourth argument),

;* Key3 (sixth argument), and Order3 (seventh argument).

;**********************************************************************

$oXL.Selection.Sort ($oXL.Worksheets(1).Range("A2"),2, $oXL.Worksheets(1).Range("B2"), , 1, ,, $xlGuess,1, 0,0, $xlTopToBottom)

; END CALLOUT B

Edited by randallc
Link to comment
Share on other sites

Thanks,

I can do it lots of complex ways, but i'd like to know the AutoIt COM is working OK! - Wouldn't you?

Thanks, Randall

PS1 - I would actually just call my Excel macro to do it!

PS2 - I would be interested to update my knowledge too; what is the "ScriptControl"? - not in help file?

Link to comment
Share on other sites

  • 4 weeks later...

HI i have checked V0.4 its not working Gving following error.. Please help or send working to rrohela@yahoo.com

Line 76 (File "C:\Script tool\AutoIt\Mycript\Examples\Convert\Vaconvert.au3")

$intStep += 1

$intStep ^ERROR

Error: Expected a "=" Operator in assignment statement.

Please help...

Link to comment
Share on other sites

HI i have checked V0.4 its not working Gving following error.. Please help or send working to rrohela@yahoo.com

Line 76 (File "C:\Script tool\AutoIt\Mycript\Examples\Convert\Vaconvert.au3")

$intStep += 1

$intStep ^ERROR

Error: Expected a "=" Operator in assignment statement.

Please help...

You need the beta version of autoit

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

Just played around with version 0.4 and some VB scripts from my work.

I found a "Do while - loop" in one of the scripts which was not translated.

I've added two lines to the VATable.txt file to solved this.

Do While|While|0|0|0|

Loop|WEnd|0|0|0|

Don't know if this is sufficient, but it worked for my VB script.

@bkemmler: Thanks for your work on this. ;)

Link to comment
Share on other sites

  • 2 months later...

Hi,

I have changed a converted script a little, but it still does not work to sort an excel sheet as the vbscript does.

I think there is a bug in the "sort" call in AutoIt3; any way to tell before i post it to bugs?

Thanks, Randall

......

I've explained this problem in the bugs forum.

Regards,

-Sven

Link to comment
Share on other sites

  • 2 months later...
  • 4 months later...

Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144
 
strDomain = "FABRIKAM"
strPassword = "ls4k5ywA"
strUser = "shenalan"
 
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
 
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
    strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
        strComputer & "'")
 
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    strPassword, strDomain & "\" & strUser, NULL, _
        JOIN_DOMAIN + ACCT_CREATE)

See the last 2 strings. AU3:

Const $JOIN_DOMAIN = 1
Const $ACCT_CREATE = 2
Const $ACCT_DELETE = 4
Const $WIN9X_UPGRADE = 16
Const $DOMAIN_JOIN_IF_JOINED = 32
Const $JOIN_UNSECURE = 64
Const $MACHINE_PASSWORD_PASSED = 128
Const $DEFERRED_SPN_SET = 256
Const $INSTALL_INVOCATION = 262144
 
$strDomain = "FABRIKAM"
$strPassword = "ls4k5ywA"
$strUser = "shenalan"
 
 $objNetwork = ObjCreate("WScript.Network")
$strComputer = $objNetwork.ComputerName
 
 $objComputer = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\" & _
    $strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
        $strComputer & "'")
 
$ReturnValue = $objComputer.JoinDomainOrWorkGroup($strDomain, _
    $strPassword, $strDomain & "\" & $strUser, NULL, _
        $JOIN_DOMAIN + $ACCT_CREATE)
Link to comment
Share on other sites

You should be able to use the keyword Default in place of Null.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

  • 5 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...