Jump to content

Execute somme code in variable


Recommended Posts

Hello,

Can I execute some code which is stored in a variable ? Execute function is not too complete (I can't execute RegWrite.... for example)

I want to use it in a compiled script.

Thanks,

Florian

Edited by tilb
Link to comment
Share on other sites

I'm not sure, but I don't think that you can do it directly. You can use conditionals to do it though.

$codeToRun = 'RegWrite("key")'

Select
Case StringInStr($codeToRun, "RegWrite")
    $codeToRun = StringTrimRight(StringTrimLeft($codeToRun, 9), 1);isolate arguements for function
    Local $givenArguements = StringSplit($codeToRun, ",");split each arguement
        Select
            Case $givenArguements[0] == 4
                RegWrite($givenArguements[1], $givenArguements[2], $givenArguements[3], $givenArguements[4])
            Case $givenArguements[0] == 3
                RegWrite($givenArguements[1], $givenArguements[2], $givenArguements[3])
            Case $givenArguements[0] == 2
                RegWrite($givenArguements[1], $givenArguements[2])
            Case $givenArguements[0] == 1
                RegWrite($givenArguements[1])
            Case Else
                MsgBox(0, "Error", "Invalid number of arguements for RegWrite");EDIT...missing arguements
        EndSelect
EndSelect

The only issue is that this way, you'd have to write one out for every individual command that you'd like to be able to read.

Edited by Creative

"Everything is vague to a degree you do not realize till you have tried to make it precise." - Bertrand Russell [The Philosophy of Logical Atomism]

Link to comment
Share on other sites

I want to use it in a compiled script.

No problemo! Just check out the helpfile and you'll be on your way.

AutoIt specific command Line Switches

Form1: AutoIt3.exe [/ErrorStdOut] [/AutoIt3ExecuteScript] file [params ...]

Execute an AutoIt3 Script File

/ErrorStdOut Allows to redirect fatal error to StdOut which can be captured by an application as Scite editor. This switch can be used with a compiled script.

To execute a standard AutoIt Script File 'myscript.au3', use the command:

'AutoIt3.exe myscript.au3'

Form2: Compiled.exe [/ErrorStdOut] [params ...]

Execute an compiled AutoIt3 Script File produced with Aut2Exe.

Form3: Compiled.exe [/ErrorStdOut] [/AutoIt3ExecuteScript file] [params ...]

Execute another script file from a compiled AutoIt3 Script File. Then you don't need to fileinstall another copy of AutoIT3.exe in your compiled file.

Form4: AutoIt3.exe [/ErrorStdOut] /AutoIt3ExecuteLine "command line"

Execute one line of code.

To execute a single line of code, use the command:

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

The tray icon will not be displayed when using /AutoIt3ExecuteLine

NOTE: Correct usage of single- and double- quotation marks is important, even double single.

What you are looking for is this line
Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'')"')

#)

Edited by nfwu
Link to comment
Share on other sites

  • 2 weeks 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...