Setting Icons added as resource to .exe

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
NightmareQueenJune
Posts: 2
Joined: 28 Mar 2024, 18:26

Setting Icons added as resource to .exe

28 Mar 2024, 18:36

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?
lexikos
Posts: 9780
Joined: 30 Sep 2013, 04:07
Contact:

Re: Setting Icons added as resource to .exe

28 Mar 2024, 18:54

"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.
NightmareQueenJune
Posts: 2
Joined: 28 Mar 2024, 18:26

Re: Setting Icons added as resource to .exe

28 Mar 2024, 19:42

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.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: DavidP, prius1234, vanove and 85 guests