ElBarteros Posted August 2, 2007 Share 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) Link to comment Share on other sites More sharing options...
qazwsx Posted August 2, 2007 Share 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 Link to comment Share on other sites More sharing options...
ElBarteros Posted August 2, 2007 Author Share 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 Link to comment Share on other sites More sharing options...
MHz Posted August 2, 2007 Share 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') Link to comment Share on other sites More sharing options...
ElBarteros Posted August 2, 2007 Author Share 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 Link to comment Share on other sites More sharing options...
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