Jump to content

Use VBscript with AutoIt : a method


 Share

Recommended Posts

Use VBS with AutoIt ? It's possible. It's easy.

Follow this example :

;;; Michel Claveau Informatique

;;; http://mclaveau.com

$code=                "Function mul2(x)"

$code=$code & @CRLF & "mul2=x*2"

$code=$code & @CRLF & "end Function"

$code=$code & @CRLF

$code=$code & @CRLF & "Function mul3(x)"

$code=$code & @CRLF & "mul3=x*3"

$code=$code & @CRLF & "end Function"

$code=$code & @CRLF

$code=$code & @CRLF & "Function mul4(x)"

$code=$code & @CRLF & "mul4=x*4"

$code=$code & @CRLF & "end Function"

MsgBox(0,"Code VBS définit :",$code)

$vbs = ObjCreate("ScriptControl")

$vbs.language="vbscript"

$vbs.addcode($code)

$vbs.eval("MsgBox(""VBscript commence"",vbinformation,""Salut"")")

$retour = $vbs.eval("mul2(123)")

MsgBox(0,"Valeur retournée par VBS",$retour)

$v=222

$retour = $vbs.run("mul3",$v)

MsgBox(0,"Avec passage de paramètre",$retour)

$retour = $vbs.run("mul4",$v)

MsgBox(0,"Test de vérification",$retour)

(And, like said : MHz : Latest Autoit Beta Version is required)

ça s'arrose, non ? Tchin-tchin à tous ! :)

Edited by Michel Claveau
Link to comment
Share on other sites

Use VBS with AutoIt ?  It's possible. It's easy.

Follow this example : 

ça s'arrose, non ?  Tchin-tchin à tous !    :)

<{POST_SNAPBACK}>

ERROR: ObjCreate(): undefined function.

                      $vbs = ObjCreate("ScriptControl)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Michel,

I received this message when running your script. What up??? :D

Link to comment
Share on other sites

Hi !

With COM's calls, for play VBS, it's possible to share variables with AutoIt.

But, for me, it was only un fun test...

:)

<{POST_SNAPBACK}>

looks like this method would make a good .vbs to exe wrapper,

if you complied the .au3

I've been on the net so long, I remember when I could only e-mail myself!

Link to comment
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
 Share

  • Recently Browsing   0 members

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