Sign in to follow this  
Followers 0
Leoly

How to run a script from a variable?

5 posts in this topic

I would like to run an exefile compiled from a script, by choosing the parameters to generate a script, and then execute it. how to doing?

Share this post


Link to post
Share on other sites



Hi leoly...

I don't know if this is what you really want.. save your compile-to-be script as something.au3 then compile your script using command line...

Save as au3 function:

$file = FileOpen("something.au3", 1)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

$a = 'MsgBox(0,"","test..")' ; your script goes here
FileWriteLine($file, $a)

FileClose($file)

Compile from command line...:

$aut2exePath = "C:\AutoIt\Aut2Exe\Aut2exe.exe" ; autoit compiler
$au3 = "C:\Documents and Settings\User\Desktop\something.au3" ; to-be-compile au3 file
Run (''&$aut2exePath&' /in "'&$au3&'"') ; run aut2exe and compile something.au3

Hi ;)

Share this post


Link to post
Share on other sites

I would like to run an exefile compiled from a script, by choosing the parameters to generate a script, and then execute it. how to doing?

Did u want this done in another AutoIt program?

An example might help here.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi leoly...

I don't know if this is what you really want.. save your compile-to-be script as something.au3 then compile your script using command line...

Save as au3 function:

$file = FileOpen("something.au3", 1)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

$a = 'MsgBox(0,"","test..")' ; your script goes here
FileWriteLine($file, $a)

FileClose($file)

Compile from command line...:

$aut2exePath = "C:\AutoIt\Aut2Exe\Aut2exe.exe" ; autoit compiler
$au3 = "C:\Documents and Settings\User\Desktop\something.au3" ; to-be-compile au3 file
Run (''&$aut2exePath&' /in "'&$au3&'"') ; run aut2exe and compile something.au3

I don't want to save my script to a file, but to implement this script directly from memory.

I have to-be-compile a au3file to exe, it can generate a string variable, like:

$script = '$a = 1'
$script &= @LF&'$b = "2"'
$script &= @LF&'if $a = $b then'
$script &= @LF&'msgbox(0,"","$a = $b")'
$script &= @LF&'endif'
$script &= @LF&'exit'

now, don't save $script to a file, how to execute it?

I know that to execute a single line of code, use the command:

Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'')"')

but how to execute multi-line of code?

Edited by Leoly

Share this post


Link to post
Share on other sites

Not sure why you are proceeding the way you are but have a look at Execute.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


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
Sign in to follow this  
Followers 0