Convert a Script to an EXE (Ahk2Exe), questions and suggestions

Share your ideas as to how the documentation can be improved.
User avatar
mslonik
Posts: 144
Joined: 21 Feb 2019, 04:38
Location: Poland
Contact:

Convert a Script to an EXE (Ahk2Exe), questions and suggestions

05 May 2021, 15:48

Dear Forum,

In this article I miss the following information:
  1. What is the /bin parameter? What is it needed for? Where to find it? Is it mandatory? What are the consequences of choosing particular file?
  2. What is the relationship between the /bin parameter and the /ahk parameter? E.g. what are the consequences if /bin parameter is missing and /ahk is present?
  3. Is the /ahk parameter mandatory? Can it point to any of the /bin executables?
  4. More general question: which parameters are mandatory and which are not?
My suggestion: please submit answers to above questions directly in documentation.

As I understood after try and error attempts and trying Gui version of the Ahk2Exe:
  • /bin is the name for AutoHotkey executable (.exe) and it is one of the following: AutoHotkeyA32.exe, AutoHotkeyU32.exe, AutoHotkeyU64.exe,
  • the /bin files are wrapped into output executable by Ahk2Exe in order to enable auto execution of the compiled script,
  • if /bin parameter isn't specified, then default one executable (.exe) is wrapped into output executable; another words this parameter isn't mandatory,
  • /ahk parameter isn't mandatory too; it's used in order to specify the default /bin.
Hopefully I'm correct with above information.

Kind regards, mslonik (🐘)

My scripts on this forum: Hotstrings Diacritic O T A G L E
Please become my patreon: Patreon👍
Written in AutoHotkey text replacement tool: Hotstrings.technology
Courses on AutoHotkey :ugeek:
TAC109
Posts: 1098
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Convert a Script to an EXE (Ahk2Exe), questions and suggestions

05 May 2021, 23:24

mslonik wrote:
05 May 2021, 15:48
Dear Forum,

In this article I miss the following information:
  1. What is the /bin parameter? What is it needed for? Where to find it? Is it mandatory? What are the consequences of choosing particular file?
The .bin files contain a special version the AutoHotkey interpreter, a copy of which is used in conjunction with the script and any other resources needed to create the final compiled executable. They correspond to the versions of the AutoHotkey executables (ANSI, Unicode 32-bit, and Unicode 64-bit) plus a default version corresponding to the default version of AutoHotkey that was installed.

[*]What is the relationship between the /bin parameter and the /ahk parameter? E.g. what are the consequences if /bin parameter is missing and /ahk is present?
The /ahk parameter is provided for exceptional purposes and is not normally used. Ahk2Exe will be able to find the relevant copy of AutoHotkey.exe to use in a normal installation.

[*]Is the /ahk parameter mandatory? Can it point to any of the /bin executables?
The .bin files are not normal executables and /ahk should not be used in this way.

[*] More general question: which parameters are mandatory and which are not?
All parameters which are shown in the documentation as having defaults are optional. In other words all are optional except the /in parameter which is mandatory unless the /GUI parameter is used.

As I understood after try and error attempts and trying Gui version of the Ahk2Exe:
  • /bin is the name for AutoHotkey executable (.exe) and it is one of the following: AutoHotkeyA32.exe, AutoHotkeyU32.exe, AutoHotkeyU64.exe,
The .bin files have an extension of '.bin' and are in the Compiler directory. The files you quoted are in the AutoHotkey directory. (Check out the directory structure of a normal AutoHotkey installation, usually in C:\Program Files\AutoHotkey.)
[*] the /bin files are wrapped into output executable by Ahk2Exe in order to enable auto execution of the compiled script,
Correct
[*] if /bin parameter isn't specified, then default one executable (.exe) is wrapped into output executable; another words this parameter isn't mandatory,
Not really see above.
[*] /ahk parameter isn't mandatory too; it's used in order to specify the default /bin.
Yes, No, see above.

I hope this clarifies matters for you.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
User avatar
mslonik
Posts: 144
Joined: 21 Feb 2019, 04:38
Location: Poland
Contact:

Re: Convert a Script to an EXE (Ahk2Exe), questions and suggestions

06 May 2021, 13:06

@TAC109,

at first thank you for detailed explanation. It is appreciated! 🙂 👍 🙂

Majority of my questions have came from the fact I couldn't find answers in documentation. This is why I've chosen this subforum on purpose to ask questions. In my opinion it could be improved with aid of your answers.

Especially the following answer helped me to understand the purpose ob /bin parameter:
The .bin files have an extension of '.bin' and are in the Compiler directory. The files you quoted are in the AutoHotkey directory. (Check out the directory structure of a normal AutoHotkey installation, usually in C:\Program Files\AutoHotkey.)

The .bin files contain a special version the AutoHotkey interpreter, a copy of which is used in conjunction with the script and any other resources needed to create the final compiled executable. They correspond to the versions of the AutoHotkey executables (ANSI, Unicode 32-bit, and Unicode 64-bit) plus a default version corresponding to the default version of AutoHotkey that was installed.
What isn't still clear to me:
  • What is the purpose of /ahk parameter? Another words: when should I pay attention to it?
Kind regards, mslonik (🐘)

My scripts on this forum: Hotstrings Diacritic O T A G L E
Please become my patreon: Patreon👍
Written in AutoHotkey text replacement tool: Hotstrings.technology
Courses on AutoHotkey :ugeek:
TAC109
Posts: 1098
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Convert a Script to an EXE (Ahk2Exe), questions and suggestions

06 May 2021, 16:55

What is the purpose of /ahk parameter?
Some users of the complete AutoHotkey package wish to have multiple versions of AutoHotkey on their system, but with just one copy of Ahk2Exe. To achieve this they set up a nonstandard directory layout to hold the various versions (such as v1 and v2), and in this case Ahk2Exe has to be told the location of the relevant AutoHotkey.exe program to use.

Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
User avatar
mslonik
Posts: 144
Joined: 21 Feb 2019, 04:38
Location: Poland
Contact:

Re: Convert a Script to an EXE (Ahk2Exe), questions and suggestions

08 May 2021, 03:54

@TAC109,

thank you again for the valuable feedback! 🙂👍🙂

Continuing, based on your feedback I tried to sketch two scenarios:
  • 1. Default tool set accompanying to Ahk2Exe.exe and including that .exe.
  • 2. Specific tool set accompanying to Ahk2Exe.exe and including that .exe.
By default the set of accompanying tools one can understand: interpreter (.bin) and AutoHotkey.exe installed in default locations under default file names.
By specific the set of accompanying tools one can understand: specific type of interpreter (.bin) and AutoHotkey.exe and/or interpreter file name installed in specific location under specific name.

For clarity each set contains only components necessary to get executable, so for example icon, compression, codepage aren't taken into account.

If I understand correctly it boils down to the 3 following components:
  1. Compiler itself (Ahk2Exe.exe)
  2. Interpreter (*.bin)
  3. AutoHotkey.exe

    Ad. 1.

    Code: Select all

                              +--------------------+                               
                              | Default Interpreter|                               
                              | (*.bin)            |                               
                              +----------|---------+                               
                                         |                                         
                                         |                                         
                                         |                                         
    +--------------+          +----------v---------+           +----------------+  
    | Input:       |          | Compiler           |           | Default Output:|  
    | MyScript.ahk ---------->| (Ahk2Exe.exe)      |-----------| MyScript.exe   |  
    | (/in)        |          +--------------------+           +----------------+  
    +--------------+                     ^                                         
                                         |                                         
                                         |                                         
                              +----------v---------+                               
                              | Default ???        |                               
                              | (AutoHotkey.exe)   |                               
                              +--------------------+                               
                                                                                  
    Ad. 2.

    Code: Select all

                                                                                   
                              +---------------------+                              
                              |Specific Interpreter |                              
                              |(*.bin)              |                              
                              |/bin                 |                              
                              +----------|----------+                              
                                         |                                         
                                         |                                         
                                         |                                         
    +--------------+          +----------v----------+           +-----------------+
    | Input:       |          | Compiler            |           | Specific Output:|
    | MyScript.ahk |--------->| (Ahk2Exe.exe)       |---------->| MyScript.exe    |
    | (/in)        |          +----------^----------+           | (/out)          |
    +--------------+                     |                      +-----------------+
                                         |                                         
                                         |                                         
                              +----------v----------+                              
                              | Specific ???        |                              
                              | (AutoHotkey.exe)    |                              
                              | /ahk                |                              
                              +---------------------+                             
    My questions:
    • Are my sketches close to reality in your opinion?
    • What parts are taken from AutoHotkey.exe in order to have running output file?
    • How you'd call AutoHotkey.exe in that process (e.g. *.bin file is called Interpreter)?
    Kind regards, mslonik (🐘)
Last edited by mslonik on 09 May 2021, 16:40, edited 1 time in total.

My scripts on this forum: Hotstrings Diacritic O T A G L E
Please become my patreon: Patreon👍
Written in AutoHotkey text replacement tool: Hotstrings.technology
Courses on AutoHotkey :ugeek:
TAC109
Posts: 1098
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Convert a Script to an EXE (Ahk2Exe), questions and suggestions

08 May 2021, 18:13

AutoHotkey.exe is used by Ahk2Exe as a utility program for supplying a list of auto-included functions used by the script. It is also used by Ahk2Exe to execute any Obey compiler directives encountered in the script. So I suppose the links to AutoHotkey.exe in your diagrams should be two-way. No parts are taken from AutoHotkey.exe directly.

If AutoHotkey.exe cannot be found by Ahk2Exe a warning message is shown during the conversion, and if the user continues, any of the above options present in the script will not be included correctly in the generated .exe.

Although, for simplicity’s sake I say that Ahk2Exe uses 'AutoHotkey.exe' for these tasks, in fact (when no /ahk parameter is supplied) it may select one of AutoHotkeyU32.exe, AutoHotkeyA32.exe, or AutoHotkey.exe, all in the directory above that containing the compiler, or as a last resort the installed AutoHotkey.exe.

Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
User avatar
mslonik
Posts: 144
Joined: 21 Feb 2019, 04:38
Location: Poland
Contact:

Re: Convert a Script to an EXE (Ahk2Exe), questions and suggestions

09 May 2021, 16:41

@TAC109
Thank you again for your help and provided explanations!

PS. I've updated my diagrams, as suggested.

Kind regards, mslonik (🐘)

My scripts on this forum: Hotstrings Diacritic O T A G L E
Please become my patreon: Patreon👍
Written in AutoHotkey text replacement tool: Hotstrings.technology
Courses on AutoHotkey :ugeek:

Return to “Suggestions on Documentation Improvements”

Who is online

Users browsing this forum: No registered users and 2 guests