I recently released my
BatteryDeley laptop low battery alert and had a bit of figuring out how to get my own icons into the compiled .exe file. While I still remember how, I'm writing it down here for others.
Update (March 2011): The new AutoHotkey requires an addition to the code to set the tray icon:Code:
;set tray icon
if A_IsCompiled
Menu, Tray, Icon, %A_ScriptFullPath%, -159
Pre-Lesson Preparation- Install Compile_AHK_II
- Download program Compile_AHK II and install.
Download from:
http://www.autohotkey.net/~ladiko/Compi ... _Setup.exe
The related forum post is: Compile_AHK II - for those who compile!
http://www.autohotkey.com/forum/viewtopic.php?t=22975
- Download the testicons.zip and extract the files.
http://www.autohotkey.net/~deleyd/testi ... ticons.zip
Lesson 1: The Default Icons- Right-click on TestIcons.ahk, select "Compile with options"
- Select the 'Icons' tab
(If the text is German, and you're not fluent in German, select the 'Sprache' combo box on the far right of the tabs and choose "en-us")

You get 7 icons. Leave them all blank for now.
- Click 'Compile' (lower left)
- Find and run your resulting TestIcons.exe program.
Notice the AutoHotkey 'H' icon in the system tray. Right-click it and select 'About'

These are the 7 default icons you get (notice there is no Icon8):

Lesson 2: Add Our Own IconUpdate (March 2011): The new AutoHotkey requires an addition to the code to set the tray icon:Code:
;set tray icon
if A_IsCompiled
Menu, Tray, Icon, %A_ScriptFullPath%, -159
Recompile and this time add our own icon.
- Right-click on TestIcons.ahk and select "Compile with options"
- Select the 'Icons' tab
- Check the box for the first one and select file battery_16x16.ico

- Click 'Compile' (lower left)
- Find and run your resulting TestIcons.exe program.
Notice the battery icon in the system tray. Right-click it and select 'About'


Lesson 3: Creating a Multiple-Icon .ICO fileIt's possible for an .ICO file to have different sizes of (usually) the same icon.
For example, an ICO icon file can have a 16x16 image and also a 32x32 image.
To create a .ICO file with both a 16x16 image and also a 32x32 image:
- Download & install the free program Icon Sushi
http://www.towofu.net/soft/e-aicon.php - load file battery_16x16.ico
- load file battery_32x32.ico
- select both,

- FILE -> SAVE AS MULTIPLE ICON
save it as battery16+32.ico
We can check our new icon file by loading it into
IrfanViewand clicking the Previous Page / Next Page buttons:

Lesson 4: Add Our Own Multiple-Icon .ICO fileRecompile and this time add the new icon we just created.
- Right-click on TestIcons.ahk, select "Compile with options"
- Select the 'Icons' tab
- Check the box for the first one and select battery16+32.ico (the .ico file we just created in the previous step)

- Click 'Compile' (lower left)
- Find and run your resulting TestIcons.exe program.

Notice the small 16x16 size icon is used for the system tray, while the larger 32x32 size icon is used where 32x32 size is needed. Both are in battery16+32.ico. Which one gets used depends on what size is needed.
Lesson 5: Add A Duck IconRecompile and this time add both the new icon we just created and the duck icon.
- Right-click on TestIcons.ahk, select "Compile with options"
- Select the 'Icons' tab
- Check the box for the first one and select battery16+32.ico
- Check the box for the second one and select duck.ico

- Recompile and run

Epilogue
And now you can check the TestIcons.ahk source code to see how the icons are accessed.
—David Deley
http://members.cox.net/deleyd/