Jump to content

Run Code from Text.txt File


Recommended Posts

Hello iam new at AutoIt and sorry for my bad english.

I search for a solution to run code from a text file. For example in the Textfile is this: MsgBox(0, "Hello World")

i hope here is any body how can help me.

here my first try:

CODE

$file = FileOpen("Test.txt", 0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

; here is my code, but how can i run it as real code

$line

Wend

FileClose($file)

Link to comment
Share on other sites

Hello iam new at AutoIt and sorry for my bad english.

I search for a solution to run code from a text file. For example in the Textfile is this: MsgBox(0, "Hello World")

i hope here is any body how can help me.

Welcome,

Try this example:

FileWrite('Test.txt', 'MsgBox(0, "title1", "Hello World")' & @CRLF & 'MsgBox(0, "title2", "Hello World")')
RunWait('"' & @AutoItExe & '" /AutoIt3ExecuteScript Test.txt')
FileDelete('Test.txt')

:)

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...