Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

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

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by TAC109 » 23 Apr 2022, 18:52

As you have discovered, Compile_AHK II is not compatible with recent versions of Ahk2Exe. Even with your suggested use of locking in an earlier version of Ahk2Exe, some scripts could be compiled incorrectly depending on the file version number selected in the GUI.

However most facilities offered by Compile_AHK II can be achieved by using the latest Ahk2Exe and Compiler Directives in your scripts, so I would suggest that you see if you can switch over to using these instead.

Hope this helps.
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
TedStriker
Posts: 8
Joined: 30 May 2014, 13:46

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by TedStriker » 24 Apr 2022, 02:51

Hi, thanks for your answer and for your work improving ahk2exe vastly. :bravo: As the problems with compile_ahk started, I didn't see that many directives for Ahk2Exe, or I was just blind. ;)

compile_ahk copies "autohotkey.exe" to %temp%, but ahk2exe looks for AutohotkeyU32.exe on my system. So making compile_ahk to copy all .exe files to %temp% was an easy fix, but I guess I'm just beating a dead horse here. It's time to say bye bye to compile_ahk and change my scripts to AHk2exe's directives. :)

aaffe
Posts: 192
Joined: 16 Jan 2014, 04:23

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by aaffe » 25 Apr 2022, 01:12

Could someone please compile a new version of compile_ahkII?

User avatar
TedStriker
Posts: 8
Joined: 30 May 2014, 13:46

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by TedStriker » 25 Apr 2022, 04:24

aaffe wrote:
25 Apr 2022, 01:12
Could someone please compile a new version of compile_ahkII?
It's not needed anymore. Just add - see examples - to your script, right click, "Compile Script".

Code: Select all

;@Ahk2Exe-SetFileVersion 1.2.3.4
;@Ahk2Exe-SetProductVersion %A_AhkVersion%
;@Ahk2Exe-SetMainIcon test.ico
;@Ahk2Exe-ExeName test.exe
See help file for much more.

aaffe
Posts: 192
Joined: 16 Jan 2014, 04:23

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by aaffe » 25 Apr 2022, 04:26

TedStriker wrote:
25 Apr 2022, 04:24
aaffe wrote:
25 Apr 2022, 01:12
Could someone please compile a new version of compile_ahkII?
It's not needed anymore. Just add - see examples - to your script, right click, "Compile Script".

Code: Select all

;@Ahk2Exe-SetFileVersion 1.2.3.4
;@Ahk2Exe-SetProductVersion %A_AhkVersion%
;@Ahk2Exe-SetMainIcon test.ico
;@Ahk2Exe-ExeName test.exe
See help file for much more.
Thank you! Didnt know this...

aaffe
Posts: 192
Joined: 16 Jan 2014, 04:23

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by aaffe » 25 Apr 2022, 04:30

Is there something like a post-build? So I can run an exe automatically when i compiled an ahk-exe?

aaffe
Posts: 192
Joined: 16 Jan 2014, 04:23

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by aaffe » 25 Apr 2022, 04:33

Found it, thank!
PostExec

Specifies a program to be executed after a successful compilation, before (or after) any Compression is applied to the .exe.
;@Ahk2Exe-PostExec Program [parameters] [, When]

aaffe
Posts: 192
Joined: 16 Jan 2014, 04:23

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by aaffe » 25 May 2022, 07:22

- deleted-
Last edited by aaffe on 25 May 2022, 07:38, edited 1 time in total.

aaffe
Posts: 192
Joined: 16 Jan 2014, 04:23

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by aaffe » 25 May 2022, 07:23

Could please someone helP?
I need the exe-Name which will be build from the ahk-Name in the ahk2exe

This doesnt work:

Code: Select all

;@Ahk2Exe-Obey U_Name, := RegExReplace(A_ScriptFullPath,"(.*)(ahk)","$1exe")
;@Ahk2Exe-PostExec %A_ScriptDir%\test.ahk %U_Name%"
I dont want to Edit the name for the exe in every script. but want to use the same directives in every script...

Thanks.
Last edited by aaffe on 25 May 2022, 08:30, edited 1 time in total.

aaffe
Posts: 192
Joined: 16 Jan 2014, 04:23

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by aaffe » 25 May 2022, 07:37

This also doesnt work:

Code: Select all

;@Ahk2Exe-Obey exename, = StrReplace(A_ScriptFullPath,"ahk","exe")
;@Ahk2Exe-PostExec %A_ScriptDir%\test.ahk "%U_exename%"
in compile_ahkII.exe I edited the compile_ahk.ahk and inserted
fileInstall,test.ahk,D:\____BUGFIXE_____\test.ahk,0


and at the end

Runwait,D:\____BUGFIXE_____\test.ahk "%Exe_File%",,UseErrorLevel
if (ErrorLevel)
MsgBox,16,Fehler!,Fehler beim aufruf von test.ahk "%Exe_File%"
Msgbox , 262208 , %MSG_TITLE% , Everything done`, bye! , 1
_EXIT(0)

but this isnt possible in ahk2exe.exe....

TAC109
Posts: 1118
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by TAC109 » 25 May 2022, 19:56

@aaffe
It would help if you could describe in more detail what you are attempting to achieve.

Thanks
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: 1118
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by TAC109 » 26 May 2022, 17:46

@aaffe Some comments on your last post:-

To get the path and name of the compiled script, the code should be:

Code: Select all

;@Ahk2Exe-Let exename = %A_ScriptFullPath~\.[^\.]+$~.exe%
;@Ahk2Exe-PostExec "%A_ScriptDir%\test.ahk" "%U_exename%"
Also note the double-quotes around the parameters to ;@Ahk2Exe-PostExec.

You haven't stated what your test.ahk is doing, but be aware that when the ;@Ahk2Exe-PostExec command is executed, the new "%U_exename%" file has not been created yet. (At this point, the newly compiled .exe is in a work file which can be accessed from the "%A_WorkFileName%" variable.)

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

aaffe
Posts: 192
Joined: 16 Jan 2014, 04:23

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by aaffe » 30 May 2022, 00:58

TAC109 wrote:
26 May 2022, 17:46
@aaffe Some comments on your last post:-

To get the path and name of the compiled script, the code should be:

Code: Select all

;@Ahk2Exe-Let exename = %A_ScriptFullPath~\.[^\.]+$~.exe%
;@Ahk2Exe-PostExec "%A_ScriptDir%\test.ahk" "%U_exename%"
Also note the double-quotes around the parameters to ;@Ahk2Exe-PostExec.

You haven't stated what your test.ahk is doing, but be aware that when the ;@Ahk2Exe-PostExec command is executed, the new "%U_exename%" file has not been created yet. (At this point, the newly compiled .exe is in a work file which can be accessed from the "%A_WorkFileName%" variable.)

Cheers
thank you very much Tac109!
Yes, I need to have the compiled exe to exist when I post its name agains test.ahk. I do some things like virus scan for the exe and sign the exe with a certificate.
With Compile_ahkII I could do this. Is there no possibility to do something when the exe exists with ahk2exe?
Thank you very much!
And how did you do this to get the exe name? It really works, thanks. Looks a bit like regex...

TAC109
Posts: 1118
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by TAC109 » 30 May 2022, 04:57

Rather than use the ;@Ahk2Exe-PostExec method, you are probably best to write your script to RunWait Ahk2Exe with appropriate parameters, then do the scanning and signing after Ahk2Exe has finished. You can test the error code returned from Ahk2Exe to see if the compile worked.

So rather than having Ahk2Exe run your script, your script runs Ahk2Exe instead.

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

aaffe
Posts: 192
Joined: 16 Jan 2014, 04:23

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by aaffe » 30 May 2022, 05:06

TAC109 wrote:
30 May 2022, 04:57
Rather than use the ;@Ahk2Exe-PostExec method, you are probably best to write your script to RunWait Ahk2Exe with appropriate parameters, then do the scanning and signing after Ahk2Exe has finished. You can test the error code returned from Ahk2Exe to see if the compile worked.

So rather than having Ahk2Exe run your script, your script runs Ahk2Exe instead.

Cheers
Ok thanks.
Are you thinking of including an after-compiling-section in ahk2exe?
This would be very helpful.

TAC109
Posts: 1118
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by TAC109 » 30 May 2022, 16:22

aaffe wrote:
30 May 2022, 05:06
Are you thinking of including an after-compiling-section in ahk2exe?
No plans at present as this can be easily achieved as stated above.
And how did you do this to get the exe name?
See this section of the help, just above the RegEx examples.

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

aaffe
Posts: 192
Joined: 16 Jan 2014, 04:23

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by aaffe » 31 May 2022, 00:49

TAC109 wrote:
30 May 2022, 16:22
aaffe wrote:
30 May 2022, 05:06
Are you thinking of including an after-compiling-section in ahk2exe?
No plans at present as this can be easily achieved as stated above.
Cheers
Ok, thats a pity. Because then I also have to change the "compile"-key in registry to my own exe and then call ahk2exe.exe with parameters from there. I use to compile on several computers. So I would have to change this at all of them and copy my own exe there and manipulate the registry there.
I think I´m gonna use Compile_AhkII for so long because it still works how described.
But thanks for your work and your answers!

TAC109
Posts: 1118
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by TAC109 » 04 Jun 2022, 17:23

@aaffe
From my research it appears that renaming an executable does not invalidate its digital signature. (This renaming is done by Ahk2Exe at the final stage of compilation.)

Therefore you should be able to use the ;@Ahk2Exe-PostExec compiler directive with the 'when' parameter set to 0, 1, or 2 , depending on your compression setting, to digitally sign your executable and perform any other processing required. You would use the "%A_WorkFileName%" parameter to access the compiled .exe.

If you want to handle any compression setting, just use 3 ;@Ahk2Exe-PostExec directives each with its 'when' parameter set to 0, 1, or 2, all calling the same code. Only one will be executed, depending on the compression setting.

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

aaffe
Posts: 192
Joined: 16 Jan 2014, 04:23

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by aaffe » 07 Jun 2022, 01:40

TAC109 wrote:
04 Jun 2022, 17:23
@aaffe
From my research it appears that renaming an executable does not invalidate its digital signature. (This renaming is done by Ahk2Exe at the final stage of compilation.)

Therefore you should be able to use the ;@Ahk2Exe-PostExec compiler directive with the 'when' parameter set to 0, 1, or 2 , depending on your compression setting, to digitally sign your executable and perform any other processing required. You would use the "%A_WorkFileName%" parameter to access the compiled .exe.

If you want to handle any compression setting, just use 3 ;@Ahk2Exe-PostExec directives each with its 'when' parameter set to 0, 1, or 2, all calling the same code. Only one will be executed, depending on the compression setting.

Cheers
thank you Tac109.
I think I don´t understand the ahk2exe-definitions at all. Could you please give me an Example how to solve this?

Runwait,D:\____BUGFIXE_____\do_signaturing_and_other_things.ahk "%Exe_File%"

TAC109
Posts: 1118
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Compile_AHK II - for those who compile! [v0.9.2 (04/19/16)]

Post by TAC109 » 07 Jun 2022, 02:30

@aaffe

Code: Select all

;@Ahk2Exe-PostExec "D:\____BUGFIXE_____\do_signaturing_and_other_things.ahk" "%A_WorkFileName%", 0
;@Ahk2Exe-PostExec "D:\____BUGFIXE_____\do_signaturing_and_other_things.ahk" "%A_WorkFileName%", 1
;@Ahk2Exe-PostExec "D:\____BUGFIXE_____\do_signaturing_and_other_things.ahk" "%A_WorkFileName%", 2
The first line is executed by Ahk2Exe if there is no compression specified, or the second line is executed by Ahk2Exe if MPRESS compression is specified, or the third line is executed by Ahk2Exe if UPX compression is specified. If you always use the same compressor or always have no compression specified, then you only need the relevant line of code, but it is not a problem to always include all three lines.

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

Post Reply

Return to “Scripts and Functions (v1)”