ElBarteros Posted August 2, 2007 Posted August 2, 2007 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)
qazwsx Posted August 2, 2007 Posted August 2, 2007 (edited) Use the execute command. But keep in mind execute is ver limited and i don't think it can run Msgbox. Edited August 2, 2007 by sccrstvn93
ElBarteros Posted August 2, 2007 Author Posted August 2, 2007 Thx it works perfekt. I have try the Execute($line) command also before but only with the MsgBox for Testing ;-) Thx for you fast reply
MHz Posted August 2, 2007 Posted August 2, 2007 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')
ElBarteros Posted August 2, 2007 Author Posted August 2, 2007 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') Yeah thats great. It is much better. And the MsgBox ... works too. big thx
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now