AutoHotkey Community

It is currently May 27th, 2012, 3:29 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: February 16th, 2009, 8:40 am 
Offline

Joined: March 8th, 2008, 11:36 am
Posts: 64
Location: Santa Barbara
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
  1. Install Compile_AHK_II
    1. 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
  2. Download the testicons.zip and extract the files.
    http://www.autohotkey.net/~deleyd/testi ... ticons.zip


Lesson 1: The Default Icons
  1. Right-click on TestIcons.ahk, select "Compile with options"
  2. 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")

    Image

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

    Image

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

    Image


Lesson 2: Add Our Own Icon

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

Recompile and this time add our own icon.
  1. Right-click on TestIcons.ahk and select "Compile with options"
  2. Select the 'Icons' tab
  3. Check the box for the first one and select file battery_16x16.ico

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

    Image

    Image


Lesson 3: Creating a Multiple-Icon .ICO file

It'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:

  1. Download & install the free program Icon Sushi
    http://www.towofu.net/soft/e-aicon.php
  2. load file battery_16x16.ico
  3. load file battery_32x32.ico
  4. select both,

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

Image

Image



Lesson 4: Add Our Own Multiple-Icon .ICO file

Recompile and this time add the new icon we just created.
  1. Right-click on TestIcons.ahk, select "Compile with options"
  2. Select the 'Icons' tab
  3. Check the box for the first one and select battery16+32.ico (the .ico file we just created in the previous step)

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

    Image

    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 Icon

Recompile and this time add both the new icon we just created and the duck icon.
  1. Right-click on TestIcons.ahk, select "Compile with options"
  2. Select the 'Icons' tab
  3. Check the box for the first one and select battery16+32.ico
  4. Check the box for the second one and select duck.ico

    Image
  5. Recompile and run

    Image



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/

_________________
http://www.autohotkey.net/~deleyd/xprxm ... amples.htm


Last edited by deleyd on March 30th, 2011, 7:03 pm, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2009, 10:03 am 
@ deleyd
what about to move that HowTo into Scripts & Functions (which is more that kind of archive for 'finished' projects)?!
Or (like the incredible SKAN has done, with his WinSpector-HowTo) drop it at Utilities & Resources?!

Anyway, thx for sharing your time 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2009, 12:38 pm 
Very nice tutorial! 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2009, 7:00 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
Well done! The more AHK tutorials like this we can get, the better. I've linked to this thread in the Wiki.

I think it's fine to keep it in the Help forum. It's still searchable, and the Help forum does say, "Post helpful tips and tricks." Perhaps if you PM'd ladiko, he would put a link at the beginning of his Compile_AHK thread, since this tutorial relates to it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2009, 2:05 am 
Offline

Joined: March 8th, 2008, 11:36 am
Posts: 64
Location: Santa Barbara
Maybe we need a Tutorials forum. I asked earlier where to put Tutorials and I get different answers from different people.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2009, 6:55 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
I wish there were enough Tutorials written to justify a forum. Until then, listing them in the Wiki and hosting them on the forum works fine (IMO it doesn't really matter which forum). The Wiki doesn't get enough traffic to be worth hosting anything there; and maybe I'm just used to it, but I like the format of the forum better anyway.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2009, 5:25 am 
Offline

Joined: February 14th, 2008, 10:07 pm
Posts: 72
Location: Santa Clara, CA
Excellent tutorial!

I'll be spending some quality time with it in the near future :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 25th, 2010, 3:59 am 
This deleted my original script when I compiled. Why in the world would you want that? Or am I missing something? Thank god I backed it up! :roll:


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group