Upcoming Ahk2Exe Changes (2024)

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2023)

Post by JoeWinograd » 15 Apr 2023, 15:33

Thanks for the link to that lexikos thread. So far, all the examples there are coming up empty, but I'll keep at it:

EnumResources.png
EnumResources.png (2.25 KiB) Viewed 3005 times

Regards, Joe

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

Re: Upcoming Ahk2Exe Changes (2023)

Post by TAC109 » 15 Apr 2023, 19:31

@JoeWinograd
I suppose it depends on how tricky you want to make it :)

Code: Select all

#NoEnv                               ; For performance & future compatibility
#Warn                                ; For catching common errors
SendMode Input                       ; For superior speed and reliability
SetWorkingDir %A_ScriptDir%          ; Ensures a consistent starting directory
SetBatchLines -1                     ; Run at full speed
; ================================  Program  ============================
;@Ahk2Exe-AddResource tree.ico, 1000
Menu Tray, Add, Tree, Tree
Menu Tray, Icon, Tree, %A_AhkPath%, -1000
MsgBox Hi!
ExitApp

Tree:
MsgBox Tree!
return
(Tree.zip contains 'Tree.ico' icon)
As the menus should be set up in the script initialisation and the compiled .exe will be in the Windows file cache, there shouldn't be a significant performance overhead with this simple approach.

If you wish to extract the icons directly from the loaded .exe in memory, then @teadrinker will probably be able to supply a function to achieve this.

Cheers
Attachments
Tree.zip
(521 Bytes) Downloaded 93 times
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: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2023)

Post by JoeWinograd » 15 Apr 2023, 19:56

Hi @TAC109,
Yes, that's the code I used for the test that I mentioned in an earlier post where I tried the Ahk2Exe AddResource directive with resource number 5001 and it worked fine. The issue is to make sure that all resource numbers are unique without having to do that manually with something like ResourceHacker. Regards, Joe

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

Re: Upcoming Ahk2Exe Changes (2023)

Post by TAC109 » 15 Apr 2023, 22:23

@JoeWinograd
Perhaps I’m not seeing the problem here. If you assign unique icon resource numbers that don’t clash with any existing icon resource numbers you should be ok.
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: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2023)

Post by JoeWinograd » 15 Apr 2023, 22:43

TAC109 wrote:If you assign unique icon resource numbers that don’t clash with any existing icon resource numbers
That's the problem...how to know what resource numbers won't clash with any existing resource numbers. During my tests, I did it manually by looking at the treeview in ResourceHacker, but I'd like to have an automated, error-free way to know that my resource numbers won't clash with existing ones. Regards, Joe

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

Re: Upcoming Ahk2Exe Changes (2023)

Post by TAC109 » 15 Apr 2023, 23:27

The icon resource numbers that are pre-used are 159, 160, 206, 207, 208. 159 is the main icon, and the rest you will be familiar with. I’m afraid that I still can’t see the problem. Are other icons being added to your compiled .exe from another source?
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: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2023)

Post by JoeWinograd » 15 Apr 2023, 23:53

Yes, I'm very familiar with resource numbers 159, 160, 206, 207, 208. But I'm not very familiar with the overall issue of resource numbers and am concerned that there could be other resource numbers that would conflict with ones I choose. For example, in one of my EXE files created by Ahk2Exe, ResourceHacker shows a resource number of 211 for a menu, a resource number of 205 for a dialog, and a resource number of 212 for an accelerator. I'm guessing (and it's just a guess) that it would be a bad idea for me to use resource number 205, 211, or 212 for one of my icons. Hence, the desire to enumerate in an automated, error-free way all the resource numbers in an executable to make sure that the ones I choose don't conflict. Regards, Joe

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

Re: Upcoming Ahk2Exe Changes (2023)

Post by TAC109 » 16 Apr 2023, 00:25

@JoeWinograd
Resource numbers must be unique within resource types, but otherwise can overlap. Here I've changed the icon resource number to 1 without problems:

Code: Select all

#NoEnv                               ; For performance & future compatibility
#Warn                                ; For catching common errors
SendMode Input                       ; For superior speed and reliability
SetWorkingDir %A_ScriptDir%          ; Ensures a consistent starting directory
SetBatchLines -1                     ; Run at full speed
; ================================  Program  ============================
;@Ahk2Exe-AddResource tree.ico, 1
Menu Tray, Add, Tree, Tree
Menu Tray, Icon, Tree, %A_AhkPath%, -1
MsgBox Hi!
ExitApp
Tree:
MsgBox Tree!
return
You will see that resource 1 is also present within RCData, Version Info, and Manifest, and everything works ok.

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
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Upcoming Ahk2Exe Changes (2023)

Post by Drugwash » 16 Apr 2023, 00:50

TAC109 wrote:
16 Apr 2023, 00:25
Resource numbers must be unique within resource types, but otherwise can overlap.
Ah, that was my mistake - always thought all numbers should be unique across all resource types. What in the MS documentation could've produced such confusion so long ago...
Part of my AHK work can be found here.

User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2023)

Post by JoeWinograd » 16 Apr 2023, 05:02

TAC109 wrote:Resource numbers must be unique within resource types, but otherwise can overlap.
Drugwash wrote:Ah, that was my mistake
Likewise here! That solves the problem...great to know! Thanks much, Joe

User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Upcoming Ahk2Exe Changes (2023)

Post by JoeWinograd » 21 Apr 2023, 16:44

OK, AddResource works great to add a .ICO file that can be used with Menu,Tray,Icon statements.
Question: Is there a way to use AddResource to add a plain text file that can be used with file-reading statements (FileRead, FileReadLine, Loop,Read, etc.)? Or is FileInstall the way to go for that? Thanks, Joe

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

Re: Upcoming Ahk2Exe Changes (2023)

Post by TAC109 » 21 Apr 2023, 19:29

@JoeWinograd
'FileInstall' would be the simplest method.

If the file was added with 'AddResource', you could programmatically find it in memory (see initial DllCall code in ScriptGuard1 for method) and transfer it to a variable, but you would need to know the original file format (UTF8 or UTF16) to transfer it successfully. Once in a variable you could process it with 'Loop Parse'.

Or you may be able to do something clever using #Include to get the data into a variable directly.

Just some thoughts off the top of my head.

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

Re: Upcoming Ahk2Exe Changes (2023)

Post by JoeWinograd » 21 Apr 2023, 22:46

TAC109 wrote:'FileInstall' would be the simplest method.
Sounds right, although I appreciate your other thoughts. Regards, Joe

User avatar
RaptorX
Posts: 380
Joined: 06 Dec 2014, 14:27
Contact:

Re: Upcoming Ahk2Exe Changes (2023)

Post by RaptorX » 29 Apr 2023, 13:14

Using [v1.1.36.02e]

Not sure if anybody else is experiencing this but, right now AHK2Exe refuses to recognize v2.0 64-Bit when selected.

I have a script with the 64-Bit requirement and it keeps failing:

image.png
image.png (41.67 KiB) Viewed 2753 times
Projects:
AHK-ToolKit

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

Re: Upcoming Ahk2Exe Changes (2023)

Post by TAC109 » 29 Apr 2023, 17:57

Update - 1.1.36.02f, 30 April 2023
  • Ahk2Exe: Allows 64-bit interpreter use on 64-bit Windows.
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: 1111
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2023)

Post by TAC109 » 29 Apr 2023, 17:59

@RaptorX
Thanks for reporting. This is fixed in Ahk2Exe v1.1.36.02f.

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

Re: Upcoming Ahk2Exe Changes (2023)

Post by TAC109 » 30 May 2023, 21:50

Updates - 1.1.36.02f1, 31 May 2023
  • Ahk2Exe: (No changes).
  • BinMod: Add new parameter /ScriptGuard2pss ('Permit /script switch').
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: 1111
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2023)

Post by TAC109 » 04 Jun 2023, 17:59

Updates - 1.1.36.02f2, 05 June 2023
  • Ahk2Exe: (No changes).
  • BinMod: Fix error message.
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: 1111
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2023)

Post by TAC109 » 04 Jul 2023, 20:13

Update - 1.1.37.00a, 05 July 2023
  • Ahk2Exe: Add sub-version check for base file *.exe allowed. (Compile v2.1 scripts correctly.)
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: 1111
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2023)

Post by TAC109 » 05 Jul 2023, 19:50

Update - 1.1.37.00a, 05 July 2023
  • Ahk2Exe: Add sub-version check for base file *.exe allowed. (Compile v2.1 scripts correctly.)
See this post for download details.

Edit: Fixed link In first post.
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)”