many languages like Java have got a little helper tool in their IDE, which cares for the right import/include statements.
The helper tool adds the necessary lines for including the needed libraries(or UDFs).
This script organizes the includes for AutoIt and it can be added to SciTE4Autoit3 very easily.

If the Autoit3 exe is not found then replace this variable $(autoit3dir) by the correct path.
command.36.*.au3="$(autoit3dir)\autoit3.exe" "$(SciteDefaultHome)\OrganizeIncludes\OI_1.0.0.50.au3" "$(FilePath)"
command.36.*.au3="c:\Programme\Autoit3\autoit3.exe" "$(SciteDefaultHome)\OrganizeIncludes\OI_1.0.0.50.au3" "$(FilePath)"

3) DONE

Starting the script by hitting CTRL+SHIFT+ALT+I in Scite, it shows you what include files you need and which you do not need.
There is also a helpfile in the zip-file which shows all settings.

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

I've been using this since I started with AutoIT it's revived a LOT of old code that I would have given up on without it. BIG thanks for the update.

One little problem though (isn't there always).

I use "Kips'" TCP.au3 library for one of the programs I am working. It just happened to be the one I tried your code on and OI told me to remove TCP.AU3.The OI is telling me the sample code doesn't need to include TCP.AU3, of course it does.http://www.autoitscript.com/forum/index.php?showtopic=74325

Bummer, I have a lot of include commands inside a other included file, instead of in the main/root source file.But. Do I read your TODO's correct that this might be supported in a future version?

PS: When I try to use a build executable instead of the au3 file. The GUI is not showing in my case. (normal au3 case works fine)Using exe like this:- au3.properties: command.37.$(au3)="<myPath>\AutoIt3\SciTE\OrganizeIncludes\OrganizeIncludes.exe" "$(FilePath)"---Forgot: Win.Xp.Pro.Sp3.x86.?

OI lists all needed includes. If you included a file which internally includes a few others till now, this has no effect on OI. I decided to list all needed includes instead of checking the dependencies. From my point of view, this is better and leads to no problems, cause if you compile your script, you can use Obfuscator from Jos to strip all unneeded lines.>>> But, I'll have a look whether I can find a good logic to add the option to check includes in includes.

Yes, when you compile OI it doesn't show a GUI. It is in line 385 : If Not @Compiled Then GUISetState(@SW_SHOW)This is because, using the script as an executable should be used from the commandline. This way, you can use it even without SciTE!

I've been using this since I started with AutoIT it's revived a LOT of old code that I would have given up on without it. BIG thanks for the update.

One little problem though (isn't there always).

I use "Kips'" TCP.au3 library for one of the programs I am working. It just happened to be the one I tried your code on and OI told me to remove TCP.AU3.The OI is telling me the sample code doesn't need to include TCP.AU3, of course it does.http://www.autoitscript.com/forum/index.php?showtopic=74325

Thanks again for the great utility!

John MorrisonAKAStorm-E

Thanks too!If you are using a function from that UDF, then OI will show you. BUT, you need to tell Oi where to look for that UDF.You can add the path to your UDF via SciTE GUIOr put the UDF into the ScriptDir an check the ScriptDir in the OI GUI

I seem to remember we already had a background discussion on this last year?
AutoIt3Wrapper currently does something similar for just the Constants include files when you add the directive:

#AutoIt3Wrapper_Add_Constants= ;Add the needed standard constant include files. Will only run one time.

I would have no issue adding this Script to the standard tools but believe it would also be nice if we could run it with a directive "each time"/"one time" when you Press Run or Compile. We also need to consider how much time is added running this tool.
I had a quick look at the source of your script and it looks like most of the components for this are in place.
At first glance: things that would be required are support for these parameters on the commandline to be able to run it in batch from AutoIt3Wrapper:

@storme
Does that mean, it doesn't work for you? If so, can you send me your constellation, that I can test it myself. Thanks!

@Jos
Thanks, I will add the commandline options soon.
Although, I think, there is no need for an automated start cia Wrapper.
Checking the includes is FMPOV a task which can be done manually by CTRL+ALT+SHIFT+I when needed.
But let's see what the people say.
Besides, there also some other features which I need to add for the next version.(see ToDo list in Source code)

+1 on the automated start via Wrapper as it would save me time tracking down which includes I've forgotten or which includes I no longer need when compiling my scripts after making minor changes. While AU3Check always lets me know I've left an include out, it doesn't tell me what the include is, nor will it tell me that I no longer need an include (which is very useful in reducing the size of my compiled scripts). I know I could run OI manually every time but I'm so damn lazy

P.S. used it yesterday on several scripts I thought were OK (and finished) and it's already proven valuable in reducing the size of my compiled scripts. Mega.

PS: Xenobiologist are you deliberately stripping the input source code of linebreaks?

(I though I got a better & faster alternative RegExp for _getDeclaredIncludes(), but because of the unexpected missing linebreaks it back fired on me the moment I put in in your code for final testing. )

I'm using two variables to handle the source code. One which holds the original code and one which is stripped by every unneeded stuff like emtpy lines, comments and so on. The stripped code is used to get all the stuff done like getting used functions, used variables, declared includes ...That is why the source in that function looks the way it looks. (it is just to make the script faster!)