Introduction
This post announces an update to the enhanced version of Ahk2Exe, originally by fincs.
(Thanks to fincs for all his work and inspiration in creating this software.)
The enhanced version processes compiler directives, giving:-
Ability to change the version information (such as the name, description, version...).
Ability to add resources to the compiled script.
Ability to tweak several misc aspects of compilation.
Ability to remove code sections from the compiled script and vice versa.
This new version has been updated with all the changes and bug fixes made to the standard version of Ahk2Exe over the intervening years.
The link to the original post describing these enhancements is here.
Download
These enhancements are now included in the official AutoHotkey v1.1.33.00+ download.
If you are using AutoHotkey, version 1.1.33.02 or earlier, you may wish to download the latest beta version of Ahk2Exe 1.1.33.03_Beta_2 from here. The .zip file includes the latest documentation, and a .reg entry to create the extra context-menu entry Compile script (GUI).
Installation
First, unblock the downloaded .zip file by right-clicking it, selecting 'Properties', and ticking or pressing 'Unblock' (near the bottom). 'OK' out.
Install by copying the Ahk2Exe.exe file from the downloaded zip to the Compiler sub-directory under where AutoHotkey has been installed (Usually C:\Program Files\AutoHotkey\Compiler\).
The V1 AutoHotkey.chm file can be copied to the AutoHotkey folder (usually C:\Program Files\AutoHotkey\).
Optionally, create the extra context menu entry Compile script (GUI) by executing the Compile script (GUI).reg file. (Administrator privilege is required for this).
Bugs
Please report any problems to this thread. (Also report successful use as well!)
Updates:-
1.1.33.03_Beta_2, 26 January 2021 -
Clarifies an anti-virus warning message.
Fixes a possible spurious '#Warn Unreachable' message.
1.1.33.03_Beta_1, 6 September 2020 -
Adds parameters to the PostExec directive.
Stops Auto-Includes being executed directly by fall-through.
Uses installation 'Default to UTF-8' setting.
Allows multiple Bin directive Codepage parameters.
Sets default V2 script encoding to UTF-8.
Stops confusing error message when /exe path has '/' instead of '\'.
Warning messages now include 'Press OK to continue, Cancel to abandon' advice.
Uses correct AutoHotkey*.exe for V2 compiles.
(Older fixes)
Beta_9f 25 June 2020 -
Fixed starting directory for #Include.
Implemented a more robust Unicode detection method.
Beta_9e 23 June 2020 -
Changed parameter /inGui to be two parameters; /gui/in.
Changed the included regedit file to reflect this.
Fixed an error when creating the default AutoHotkeySC.bin file for v2.0.
Beta_9d 16 June 2020 -
Fixed 2 problems when compiling itself.
Fixed possible problem when running multiple compiles in parallel.
Beta_9c 10 June 2020 -
Fixed /inGui parameter so that the Gui is not closed after a compile error.
Updated help to use the AutoHotkey 'house style' (thanks Ragnar_F).
Beta_9b 30 May 2020 -
Fixed 'busy cursor' not shown while .exe being moved to final destination.
Add option to show GUI from context menu - see updated documentation.
(Use the included .reg file to create a 'Compile Script (GUI)' context menu shortcut - requires admin privilege to setup.)
Beta_9a 01 May 2020 -
Allows retrying from the error "Error opening the destination file" - This can be caused by automatic anti-virus checking.
Remembers previous script and icon folders in repeated GUI use.
Updated help file 30 January 2020 -
The Compiler Directives information has been merged into the latest AutoHotkey version 1.1.32.00 help.
Beta_9, 20 November 2019 -
UpdateManifest directive now supports 'highestAvailable' execution level, and setting UIAccess=true.
Shows warning message if MPRESS/UPX requested but not found when compiling.
Beta_8, 8 November 2019 -
GUI is now resizable.
Changed GUI 'Compress' to DDL.
Fixed GUI 'Default destination'.
Improved CLI parameter error messages.
Implemented PostExec directive 'when' parameter.
Added 'BinMod.ahk', a simple fast binary editor which can be called by 'PostExec'.
Compiler Directives documentation is now in draft AutoHotkey.chm help file (included).
Beta_7, 8 October 2019 -
A leading 'U_' (without quotes) is now accepted in the 'name' parameter of 'Let' and 'Obey' directives.
Beta_6, 29 September 2019 -
Implement the CLI /ahk parameter to specify the path\name of AutoHotkey.exe if non-standard.
(Used during the compilation process.)
Fixed bug when the path to AutoHotkey.exe contains spaces.
Fixed to allow concurrent compiles to work better.
Beta_5, 31 August 2019 -
Added optional 'Exe_path\Name', and 'Codepage' parameters to 'Bin' directive.
Added 'Cont' directive (for continuation lines to any directive).
Added optional 'Extra' parameter to the 'Obey' directive.
Changed 'UpdateManifest' directive to always require the first parameter.
Allow drag 'n drop of a non-standard *.bin file to the GUI.
Warn if UPX/MPRESS.exe are missing when cycling the 'Compress exe with' checkbox on the GUI.
See the updated documentation in the .zip for more information.
Beta_4, 22 August 2019 -
Changed 'Obey' internals to use work files.
'Obey'ing an invalid command will now show an error message.
Added 'SetFileVersion', 'SetInternalName', 'SetProductName', and 'SetProductVersion' directives.
See the updated documentation in the .zip for more information.
Beta_3, 20 August 2019 -
Fix 'Set FileVersion' and 'Set ProductVersion'.
Implement 'Save Script Settings as' on File menu.
Implement new directives 'Bin', 'ExeName' and 'Obey'.
Handle unloading and reloading for the generated .exe.
See the updated documentation in the .zip for more information.
Beta_2, 10 August 2019 -
The command line parameter /mpress has been changed to /compress. (/mpress is still accepted, though.)
Directive parameters can reference the various 'A_' built-in variables as listed under the #Include directive.
In addition the new 'A_WorkFileName' variable contains the temporary name of the processed .exe file.
The new 'A_PriorLine' variable contains the source code line immediately preceding the current compiler directive.
The value returned from variables can be manipulated using regex code.
The new 'Let' directive enables the creation of special 'U_<name>' variables.
Other new directives are 'SetLanguage', 'Set', 'UpdateManifest', and 'Debug'.
See the updated documentation in the .zip for more information.
Also included in the .zip are 2 demonstration script groups which show how the directives can be used.
Beta_1, 08 June 2019-
Added 'LegalTrademarks' property.
Added UPX .exe compression option.
Cleanup a temp file left behind.
Last edited by TAC109 on 25 Jan 2021, 18:46, edited 32 times in total.
My scripts:- XRef - Produces Cross Reference lists for scripts ReClip - A Text Reformatting and Clip Management utility
Great work!
I think I'll add a directive for Compression (MPress and maybe UPX) which will do nothing if they are unavailable.
Also, perhaps we can put this under ahkscript/ or autohotkey/
Oh! I've been waiting for this kind of thing for a while now!
So, does this require the script to be compiled via command line? Or can the executables work through the compiler nonetheless?
> So, does this require the script to be compiled via command line? Or can the executables work through the compiler nonetheless?
Works fine through the GUI compiler as long as you've copied the new Ahk2Exe.exe file to the Compiler subfolder (which is C:\Program Files\AutoHotkey\Compiler for a standard install). Regards, Joe
> a directive for Compression (MPress and maybe UPX) which will do nothing if they are unavailable
Nice idea! Another possibility on the same front is to change the Use MPRESS check-box to three radio buttons: Use MPRESS, Use UPX, Do not compress. That way, both compressors can be in the Compiler folder and it is a single mouse click to set which way to go on any particular compile. Or maybe a Compress drop-down (like the Base File one) with the three choices. Regards, Joe
Hi TAC109,
There's one other field in Properties that I set in my NSIS installers that would be a nice addition to your compiler Directives: LegalTrademarks. Thanks, Joe
Hi TAC109,
There's one other field in Properties that I set in my NSIS installers that would be a nice addition to your compiler Directives: LegalTrademarks. Thanks, Joe
I’ll look at adding this over the next few days.
Also the Mpress/Upx options on the Gui.
Cheers
My scripts:- XRef - Produces Cross Reference lists for scripts ReClip - A Text Reformatting and Clip Management utility
The compiler leaves behind a scratch file in the user temp directory. The file name is of the form "~temp82727923.tmp" with the number changing on each compile. This scratch file is actually the compiled program -- it is identical to the compiled program created in the directory with the source. Since I make many many errors, and therefore recompile and recompile and recompile, thereby creating many many many versions of these temp files in the temp directory, it would be nice if the compiler cleaned it up before closing. (There would then be less evidence of my errors.)