Page 1 of 1

Setting Icons added as resource to .exe

Posted: 28 Mar 2024, 18:36
by NightmareQueenJune
I have three Icons i've added as a resource to the .exe by using

Code: Select all

;@Ahk2Exe-AddResource game.ico, ICON1
;@Ahk2Exe-AddResource heart.ico, ICON2
;@Ahk2Exe-AddResource keyboard.ico, ICON3
When trying to access the Icons using

Code: Select all

TraySetIcon "ICON1",, true
I get an error though. Sadly I couldn't find anything helpful online. Am I missing something?

Re: Setting Icons added as resource to .exe

Posted: 28 Mar 2024, 18:54
by lexikos
"ICON1" is not a filename. The usage is TraySetIcon [FileName, IconNumber, Freeze].

AutoHotkey does not support specifying an icon resource by name. You can assign a numeric ID instead; a positive number for AddResource but prefix it with - in IconNumber.
If negative, the absolute value is assumed to be the resource ID of an icon within an executable file.
Alternatively, you can specify the sequential index of the icon resource as a positive IconNumber.

Re: Setting Icons added as resource to .exe

Posted: 28 Mar 2024, 19:42
by NightmareQueenJune
Thank you so much! After changing it to

Code: Select all

;@Ahk2Exe-AddResource game.ico, 10
TraySetIcon A_ScriptFullPath, -10, true
it works. In my despair I completely overlooked that part with the negative number.