computergeek Posted June 30, 2005 Share Posted June 30, 2005 I need to have a script that loads multiple au3 files in a certain directory and execute them. The way i do this is by performing a search for any .au3 files and then useing the #include function but this doesn't seem to work. This is probably b/c this was never its intended purpose . But i need a way to do this. Any ideas? $search = FileFindFirstFile("*") If not($search = -1) Then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $include=$file & "\" & $file & ".au3" #include $include WEnd endif Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted June 30, 2005 Share Posted June 30, 2005 the #include function is for the preprocessor, note the # (hash). That means that any preprocessor function is ran before anything else, which means that variables (even from $CmdLine) are not used. I would have suggested trying #include <*.au3> however, that's apparently not allowed (just tested, atleast Syntax Check says no). I believe that you'll just have to add a line of code for each file. Also, the way you want to do it is quite a security loop, if I create an au3 file, and put that in the same folder as the script, I can in essence do whatever I want. Also, when you compile an exe from a script, all #include functions are done at that time, which is why you have to have the filenames at compile time... Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
computergeek Posted June 30, 2005 Author Share Posted June 30, 2005 (edited) I know it's a security risk, but i needed a way to load in extra code that would increas the functioniality of the program. (And it's more for personal use) I don't know of any way to execute autoit commands after compilation nor of any before... Oh well... If anyone has any ideas, please feel free to post... Also, the reason i don't want to write it in manulay b/c the external files are suposed to act like plugins. Edited June 30, 2005 by computergeek Link to comment Share on other sites More sharing options...
Developers Jos Posted June 30, 2005 Developers Share Posted June 30, 2005 I know it's a security risk, but i needed a way to load in extra code that would increas the functioniality of the program. (And it's more for personal use) I don't know of any way to execute autoit commands after compilation nor of any before... Oh well... If anyone has any ideas, please feel free to post... Also, the reason i don't want to write it in manulay b/c the external files are suposed to act like plugins.<{POST_SNAPBACK}>Just use runwait("c:\path\Autoit3.exe " & $Filename) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
computergeek Posted June 30, 2005 Author Share Posted June 30, 2005 (edited) The problem with that is i am also useing variables that are declared in the script that is trying to call the other scripts. Unless there is a way to get those values, i won't be able to use this method. Thanks for the quick reply. I will try to fix it up so it doesn't need any vars from any remote script. Edited June 30, 2005 by computergeek Link to comment Share on other sites More sharing options...
GaryFrost Posted June 30, 2005 Share Posted June 30, 2005 Could do what jp said, but also pass command line vars SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
computergeek Posted June 30, 2005 Author Share Posted June 30, 2005 (edited) I was able to make it so that it didn't require any external variables, but is there still a way to get variable from another script so i can close the window when the main window is closed? Or can i do that by parenting it? I also need to pass on info such as window handles from the remote scripts to the main script... Edited June 30, 2005 by computergeek Link to comment Share on other sites More sharing options...
erebus Posted June 30, 2005 Share Posted June 30, 2005 I think you need to change the perspective of your code a bit. You cannot include a code in that way, you have to decide if you want that code to be included when you start your program or not. 'Include' was not made as a substitution of "goto" or "run". It is a way to add mainly global functions in your code (meaning a function file that is being shared among several scripts). What I would do is to organize the "included" code in custom functions which I would call when needed instead of calling 'include'. Hope these help, Link to comment Share on other sites More sharing options...
JSThePatriot Posted June 30, 2005 Share Posted June 30, 2005 Use the option of passing command line variables to communicate between scripts. That I would say would be your best option. If you have a GUI you could have some hidden fields that Control*() commands could access and set before the remote script closes. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
computergeek Posted June 30, 2005 Author Share Posted June 30, 2005 (edited) Thanks, i think i will try useing the command line or Control*() commands... I am going on vacation for 8 days so, i will tell u how it goes later... When i use run or runwait, i get this: C:\Documents and Settings\Computer Geek\Desktop\AutoIt\systembar\systembar.au3 (38) : ==> Unable to execute the external program.: RunWait($include) Yet the include location is correct and is formed by this: $include=@ScriptDir & "\extentions\" & $file & "\" & $file & ".au3" Here is the whole portion of the script Global $extentions[1] $search = FileFindFirstFile(@ScriptDir & "\extentions\*") If not($search = -1) Then While 1 $file = FileFindNextFile($search) ;If @error Then ExitLoop if not($file=".") AND not($file = "..") then $include=@ScriptDir & "\extentions\" & $file & "\" & $file & ".au3" _ArrayAdd ( $extentions, $file ) msgbox(1,"",$include) RunWait($include) endif WEnd endif Edited June 30, 2005 by computergeek Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted June 30, 2005 Share Posted June 30, 2005 The .au3 file is not executable. You have to do RunWait("start " & $include) That should work. Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) 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