Preparing Your Autohotkey Include Files for Obfuscation

If you have a single MainScript.ahk script file with no includes

[Version 2.11] You can skip the Include Map Text File creation and directly select your single ahk file in the Obfuscator.

If you have a script including other .ahk files

This Obfuscator does not automatically find and parse your Autohotkey #include file and make them part of the obfuscation. It is not as sophisticated as the AHK parser. Therefore you need to make some minor adaptations.

First you must move all your #include file statements in your source code to end or the beginning of your main source code file and use the 'IGNORE_BEFORE_THIS' or 'IGNORE_AFTER_THIS' Obfuscator command comments. Then to signify to the Obfuscator what files are to be included, you prepare an includes map file.

If your include statements only bring in whole functions or label sections then moving them around should not pose a problem.
If you are, however, using includes to drop code fragments in-line into other stuff and cannot move them around, then that feature is not supported by this Obfuscator.


-

Move Your '#include file Statements to the End or the Beginning of Your Source Code Files

Move your #include file statements to the end of your source code file and put this Obfuscator command comment before them:
;$OBFUSCATOR: $IGNORE_AFTER_THIS:
Or you can move them to the beginning of your source code file and put this command comment after them:
;$OBFUSCATOR: $IGNORE_BEFORE_THIS:
Which means you will have something like that:
MainScript.ahk
;[code]
;...
;$OBFUSCATOR: $IGNORE_AFTER_THIS:
;LIBRARIES
#include %A_Scriptdir%\Lib\
#include Init.ahk
#include Init_Settings.ahk
#include Init_Variables_PreInit.ahk
;XML Include
#include Includes\XML_Builder.ahk
;[END OF THE FILE]
The Obfuscator will not try to process anything before or after those tags in the current source code file. No obfuscation of those areas will be done and in fact none of the code there will be transferred to the final obfuscated code until we do the next step.

Prepare an Includes Map File

You tell the Obfuscator what files to obfuscate together by preparing an includes map file indicating your main script and all your includes.
Just prepare a pure text file '[SCRIPTNAME]_IncludeMAP.txt' in the same folder as your main script file with the file path of each file on a separate line.
You will be asked for this file when you run the Obfuscator.
The file that has your Auto-execute section on it should be listed first. The order that the remaining files are listed can make a difference because if there is an Obfuscator command comment to change obfuscation defaults for functions, then that change will remain in effect across any new source code files until a new command comment changing function defaults is found.
[DigiDon] The Include Map File can now contain relative files, directories (to change relative paths), and comments on separated lines.

For example if in your 'MainScript.ahk' you have these includes :
;$OBFUSCATOR: $IGNORE_AFTER_THIS:
;LIBRARIES
#include %A_Scriptdir%\Lib\
#include Init.ahk
#include Init_Settings.ahk
#include Init_Variables_PreInit.ahk
;XML Include
#include Includes\XML_Builder.ahk

Create a '[SCRIPTNAME]_IncludeMAP.txt' file in the same folder as your 'MainScript.ahk' file containing the 'MainScript.ahk' as the first line and then the other files to process. It can look pretty similar in this case:
MainScript.ahk
;LIBRARIES
#include %A_Scriptdir%\Lib\
#include Init.ahk
#include Init_Settings.ahk
#include Init_Variables_PreInit.ahk
;XML Include
#include Includes\XML_Builder.ahk
[Version 2.11] "#include " is now ignored and "%A_Scriptdir%\" is replaced by the main script directory for better compatibility with AHK include syntax.