Upcoming Ahk2Exe Changes (2024)

Post your working scripts, libraries and tools for AHK v1.1 and older
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2019)

10 Apr 2020, 19:42

Could you let me have the failing uncompressed .exe? You can PM me a link (or whatever you think is best).
Ta
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
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2019)

10 Apr 2020, 19:55

Before you do that, could you find which fileinstall(s) are causing the trouble?

Edit: Also, could you compile the full failing code with the ;@Ahk2Exe-PostExec BinMod lines removed/commented out?

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
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2019)

10 Apr 2020, 20:26

The script is around 1,000 lines, but I was able to reproduce the problem in a test script of fewer than 30 lines. I'll PM you a link to both the source and EXE.

While I was writing the above, your second post came in. I'll try to figure out which of the four is causing the problem. Regards, Joe

Edit: Didn't see your edit until after posting. Will try removing the BinMod first.
User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2019)

10 Apr 2020, 20:30

Ah, good call! It works fine with the BinMod removed. What does that tell you?
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2019)

10 Apr 2020, 21:54

Right!
Not fully clear at this stage. Could you PM me the test sources and .exe? Ta
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
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2019)

10 Apr 2020, 22:52

Will do. I'll try to narrow it down to a single FileInstall.
User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2019)

11 Apr 2020, 03:14

Very interesting results:

(1) With a single FileInstall, I do not get the "Could not extract script from EXE" dialog, but the installed file is 0 bytes, so the FileInstall does not work. This is true for all four file types (ICO, INI, PDF, TXT).

(2) With two FileInstall commands, I get the "Could not extract script from EXE" dialog.

Here are a few lines that create the problem...I'm confident you'll get it there, but if not, let me know:

Code: Select all

; IMPORTANT: strlen of replacement must be 19 (strlen of >AUTOHOTKEY SCRIPT<) - pad with blanks if needed - and must be all upper case
;@Ahk2Exe-PostExec "c:\temp\BinMod.exe" "%A_WorkFileName%" "22.>AUTOHOTKEY SCRIPT<.THISISCOMPANY LLC  "
FileInstall,c:\temp\test.ini,%A_ScriptDir%\test.ini,1 ; overwrite
FileInstall,c:\temp\test.txt,%A_ScriptDir%\test.txt,1 ; overwrite
MsgBox Ahk2Exe FileInstall test done
It's past 3am here and this is my last post for the night. Will check back into the thread first thing in my morning. Regards, Joe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2019)

11 Apr 2020, 05:05

Earlier you wrote:
>Edit: Btw, without MPRESS, ResourceHacker shows the script, the INI file, and the TXT file perfectly.

Now they are not ok?

It’s probably best if you send me a link to the test source files and the failed compiled .exe and I can dig into the problem here.
Also a link to the original full failed uncompressed .exe would be helpful.

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
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2019)

11 Apr 2020, 14:46

Now they are not ok?
They're still OK, i.e., without MPRESS, ResourceHacker shows the script, the INI file, and the TXT file perfectly. Here are those three files:

Script:

Code: Select all

; IMPORTANT: strlen of replacement must be 19 (strlen of >AUTOHOTKEY SCRIPT<) - pad with blanks if needed - and must be all upper case
;@Ahk2Exe-PostExec "c:\temp\BinMod.exe" "%A_WorkFileName%" "22.>AUTOHOTKEY SCRIPT<.THISISCOMPANY LLC  "
FileInstall,c:\temp\test.ini,%A_ScriptDir%\test.ini,1 ; overwrite
FileInstall,c:\temp\test.txt,%A_ScriptDir%\test.txt,1 ; overwrite
MsgBox Ahk2Exe FileInstall test done
INI file:

Code: Select all

test ini file
TXT file:

Code: Select all

test txt file
It’s probably best if you send me a link to the test source files and the failed compiled .exe and I can dig into the problem here.
The test source files are above...a five-line script, a one-line INI file, a one-line TXT file (I suspect that any two FileInstall files will create the problem).

Here's the error dialog when running the EXE:

could not extract script dialog.png
could not extract script dialog.png (3.22 KiB) Viewed 3758 times

Here's the ResourceHacker view of RCData:

rh rcdata.png
rh rcdata.png (4.28 KiB) Viewed 3758 times

Here's the ResourceHacker view of the script:

rh script.png
rh script.png (4.74 KiB) Viewed 3758 times

The ResourceHacker view of the INI file and TXT shows the one line in each fine.
Also a link to the original full failed uncompressed .exe would be helpful.
I'll PM that to you, but I'll be very surprised if you can't reproduce the problem there, unless we have different BinMod executables, since we determined that the problem goes away when the BinMod PostExec directive is removed. I'll include a link in the PM to my BinMod.exe. Regards, Joe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2019)

11 Apr 2020, 18:58

@JoeWinograd Hi Joe. Hope you slept well.
I've found the problem!

Windows apparently expects to find the resources in RCData in alphabetical order, and arranges them this way when creating the .exe. So the script resource >AUTOHOTKEY SCRIPT< appears first. When BinMod changes this name to "THISISCOMPANY LLC ", this entry becomes out of order and the .exe interpreter can't find the script. (For some reason this problem only crops up when there is more than one FileInstall.)

The simple solution would be to prefix the replacement name with (space). I've checked this works with the test data you supplied. I'll add a comment to the BinMod.ahk script on GitHub.

Can you let me know if this solves the original problem?

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
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2019)

11 Apr 2020, 20:07

Fascinating problem! Yes, the fix works perfectly on the 1,000-line script with the four FileInstall commands. I had been padding the end with two spaces to make the 19 characters, so I simply changed it to one space at the beginning and one space at the end...works a charm! Thanks for your efforts in tracking down the problem and providing a simple work-around...very much appreciated! Regards, Joe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2019)

11 Apr 2020, 20:33

I have a hypothesis as to why it worked with just 1 FileInstall, and that is that Windows uses a binary chop method to find the resource it is looking for. With 3 items it would start by looking at item 2 and deciding that it needs to look further down the list - and not find the script. With 2 items it would start by looking at item 1 and find the script immediately.

Regards
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
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2019)

11 Apr 2020, 20:40

TAC109 wrote:
11 Apr 2020, 20:33
I have a hypothesis as to why it worked with just 1 FileInstall
Well, keep in mind that it "worked" only to the extent that it did not display the "Could not extract script from EXE" dialog. But the FileInstall does not really work, as the installed file is always 0 bytes. Cheers, Joe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2019)

11 Apr 2020, 20:46

Joe, the same hypothesis would explain that anomaly as well.

BTW, thanks for the clear evidence you provided. I was able to study your screen shots, then go out for a walk. While walking a couple of likely scenarios occurred to me and, luckily, the last one was correct!

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
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2019)

11 Apr 2020, 22:43

> the same hypothesis would explain that anomaly as well

Got it.

> thanks for the clear evidence you provided

You're welcome...glad I could help.

> luckily, the last one was correct!

Nothing lucky about it. :) Cheers, Joe
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Upcoming Ahk2Exe Changes (2019)

26 Apr 2020, 14:12

does this particular version of Ahk2Exe happen to work with compiling AutoHotkey_H scripts with the proper .bin files? Or is AutoHotkey_H compiler a different project?
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2019)

26 Apr 2020, 16:00

No, this version of Ahk2Exe just handles the standard versions (v1 and v2). For AutoHotkey_H compiles you need to use the Ahk2Exe included with AutoHotkey_H.

Edit: Although AutoHotkey_H's Ahk2Exe includes some of the Compiler Directives that are in the beta version here.

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
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2019)

30 Apr 2020, 20:03

New version available -

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.
See this post for download details.
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
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2019)

29 May 2020, 22:23

New version available -

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.)
See this post for download details.
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
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2019)

09 Jun 2020, 20:13

New version available:

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).
See this post for download details.
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

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 77 guests